bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

ui bootstrap carousel animation angular 1.2.* issues

Open autumn01 opened this issue 13 years ago • 61 comments

the new implementation of ng-animate seems to be interfering with the animation for the carousel slider directive.

<div ng-class="{
    'active': leaving || (active && !entering),
    'prev': (next || active) && direction=='prev',
    'next': (next || active) && direction=='next',
    'right': direction=='prev',
    'left': direction=='next'
  }" class="item ng-scope ng-isolate-scope ng-animate ng-enter ng-animate-start ng-animate-active ng-enter-active next left" ng-transclude="" ng-repeat="slide in slides" active="slide.active" style="-webkit-transition-property: left, clip; -webkit-transition-duration: 0.6s, 0.6s; ">
...
</div>

note the extra classes. On my end this is causing flickering and

here is a coded example to explain the result http://jsfiddle.net/XxPzW/

I am trying to look into weather there is a way to disable ng-animate for a singe directive, I haven't found anything yet.

EDIT: This account is no longer used i now go by @iamlothian.

EDIT: http://plnkr.co/edit/UWDcnJ2PGZd474D5SuoS?p=preview (work around)

.directive('setNgAnimate', ['$animate', function ($animate) {
    return {
        link: function ($scope, $element, $attrs) {
            $scope.$watch( function() {
                return $scope.$eval($attrs.setNgAnimate, $scope);
            }, function(valnew, valold){
                console.log('Directive animation Enabled: ' + valnew);
                $animate.enabled(!!valnew, $element);
            });
        }
    };
}]);

Used like this:

<div ng-controller="SomeController" set-ng-animate="false">
    <carousel interval="myInterval">
        <slide ng-repeat="slideCollection in groupedSlides" active="slide.active">
            <div>
                <img ng-src="{{slideCollection.image1.image}}" style="margin:auto;">
                <img ng-src="{{slideCollection.image2.image}}" style="margin:auto;">
            </div>
        </slide>
    </carousel>
</div>

autumn01 avatar Nov 19 '13 04:11 autumn01

Until the directive is upgraded to use angular's ng-animation the directive should run

$animate.enabled(false, directiveElement);

to disable angular from allying it's own animation classes.

Here is an implementation that should work, but requires the ngAnimate module. Currently angular 1.2.1 is failing to honor this request. So that may be the cause of this issue in the first place.

http://plnkr.co/edit/UWDcnJ2PGZd474D5SuoS?p=preview (FIXED)

autumn01 avatar Nov 20 '13 01:11 autumn01

I've just tested with AngularJS 1.2.2 and things seem to be in order. Feel free to re-open the issue if needed (but please provide a reproduce scenario in plunker, jsFiddle is a pain to work with...).

pkozlowski-opensource avatar Nov 22 '13 18:11 pkozlowski-opensource

+1 - I'm seeing exactly the same issue, using the same versions of angular, angular-bootstrap and bootstrap css.

iandotkelly avatar Nov 24 '13 20:11 iandotkelly

+1 same issue

angular 1.2.2 angular-boostrap 0.7.0

gavares avatar Nov 27 '13 00:11 gavares

+1 for me as well.

wsmidt avatar Nov 27 '13 18:11 wsmidt

Updated to 1.2.3 ~~still the same issues:~~ http://plnkr.co/edit/UWDcnJ2PGZd474D5SuoS?p=preview (FIXED)

I have been talking with @matsko about it. He has said the $animate.enabled(false, directiveElement); need to be on the parent of the animation.

~~I believe we are close now. It seams to be working if you enable and then disable the animations again after load. As ng animate disables all animation on load and then enables again when angular is fully initialized i believe setting the disable flag on an element is overridden when the global animations are turned back on.~~

~~Currently the docs (http://docs.angularjs.org/api/ngAnimate.$animate) doesn't list any method for watching the state of this.~~

autumn01 avatar Dec 02 '13 00:12 autumn01

This is in progress to be fixed by angular 1.2.4 but will still require the directive to include the ngAnimate module and disable or for an external directive like the one in my example to be use to disable it until the code is re factored to use ngAnimate.

At this time i an unable to help with this effort. Maybe soon i can lean a hand.

autumn01 avatar Dec 03 '13 01:12 autumn01

Can you guys provide an extra plunkr or two which is different from the one mentioned by @autumn01?

matsko avatar Dec 03 '13 03:12 matsko

@autumn01's code had a tiny snag that was causing the animation flag not to be set (or removed) on bootstrap. So based on his example it isn't really as issue. But it also looks like others in this commit still have an issue with this. If so please provide an extra plunkr example or open an issue in the AngularJS core.

Thanks everyone.

matsko avatar Dec 03 '13 04:12 matsko

The sang (oops) is now resolved in my example: http://plnkr.co/edit/UWDcnJ2PGZd474D5SuoS?p=preview

So the issue here is no longer related to angular js but to the implementation of the current carousel directive. In my example if you remove the set-ng-animate="$parent.animate" attribute on line 47. You will see how the angular animation are interfering with UI bootstrap carousel transitions.

autumn01 avatar Dec 03 '13 04:12 autumn01

@matsko - this was my plunkr : http://plnkr.co/edit/Nqromw15crxowNqGlYBI

It's a lot simpler than @autumn01's example and still exhibits strange behavior that I did not see with 1.2.0-rc.3 ... I'm quite prepared to be told I"m doing something stupid though.

iandotkelly avatar Dec 03 '13 04:12 iandotkelly

@iandotkelly thank you for sending the link. However, I am posting in this thread form angular.js. I'm actually not familiar with ui-bootstrap, I just wanted to know if $animate was causing any issues. Looks like $animate is still a work in progress with ui-bootstrap.

matsko avatar Dec 03 '13 05:12 matsko

@matsko - thanks

iandotkelly avatar Dec 03 '13 05:12 iandotkelly

@iandotkelly Till the UI bootstrap project is re-factored here is a simplified fix http://plnkr.co/edit/8HfZCaTOIeAesKVFSFpj?p=preview

@pkozlowski-opensource This issue only happens when ngAnimate is included, so using $injector.has() (starting from AngularJS 1.1.5) to check for the existence of ngAnimate and then disabling animations for affected elements or directives might be the way to go.

autumn01 avatar Dec 03 '13 05:12 autumn01

Thanks @autumn01

iandotkelly avatar Dec 03 '13 05:12 iandotkelly

Thanks alot @autumn01 ! I've created a directive named disableNgAnimate by referring to your setNgAnimate, and it worked like a charm. I also agree that it is really necessary to refactor carousel a bit in order to take $animate into consideration.

MrOrz avatar Dec 15 '13 17:12 MrOrz

+1, came here with this: http://plnkr.co/edit/OWOqmVJnf4MyjA601zWC?p=info

intellix avatar Jan 11 '14 14:01 intellix

@intellix doesn't look like it's working.

matsko avatar Jan 13 '14 01:01 matsko

+1 seeing this issue with angular-ui bootstrap 0.9.0 and angular-animate 1.2.8

dcartertwo avatar Jan 14 '14 16:01 dcartertwo

@intellix I noticed that when you use that kind of scope variable, an object in your case, and you pass it on in the ng-repeat it will fail. If you use an array it does work. http://plnkr.co/edit/BkLD3M?p=preview

mvhecke avatar Jan 14 '14 17:01 mvhecke