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

@Gamemaniak the version I posted illustrates an issue between changing the scope with something like $timeout and that having animate breaks it. Yours is just an initial carousel that works on mine as well :D

intellix avatar Jan 14 '14 17:01 intellix

Try out 1.2.9 later today since there are a few class-based animation fixes in there.

matsko avatar Jan 14 '14 18:01 matsko

1.2.9 completely killed UI Bootstrap animations for me. 1.2.10 didn't fix anything either :D I guess right now it's best to disable ngAnimate

intellix avatar Jan 26 '14 14:01 intellix

I lost the whole morning on this. @autumn01 Thanks a lot, we'll use your solution until fix is made.

gorgi avatar Jan 31 '14 12:01 gorgi

Sorry for the troubles with ngAnimate and ui-bootstrap. Before $animate is more merged into ui-bootstrap, the internal class-based animation code will be refactored to group animations together instead of cancelling followup animations when a CSS class is added.

This is a bit complex to fix, but it should make it into the next release. Then you can use $animate with ui-bootstrap without any side-effects.

matsko avatar Feb 01 '14 04:02 matsko

@matsko no worries - better to take time and do things right! Looking forward on talking / working with you on doing the $animate thing right in this project!

pkozlowski-opensource avatar Feb 01 '14 09:02 pkozlowski-opensource

Modal show/hide is broken with ngAnimate as well -- the 'in' class never gets added/removed.

alalonde avatar Feb 13 '14 18:02 alalonde

@alalonde Until we reach the next version, ngAnimate won't help that much. We are now in the middle of supporting it.

Foxandxss avatar Feb 13 '14 22:02 Foxandxss

This is in a PR at the moment: https://github.com/angular/angular.js/pull/6267

matsko avatar Feb 14 '14 23:02 matsko

tried the 1.2.13 branch and still the carousel fails here, e.g doesn't animate nor do the next/prev work,just thought I'd add my 2c worth:)

bealtine avatar Feb 15 '14 02:02 bealtine

@bealtine can you provide a plunkr?

matsko avatar Feb 15 '14 02:02 matsko

Sure thing... http://plnkr.co/edit/yomThgyfATAXZgYXR6Hs?p=preview

Code hacked to bits from a very old project for this demo.

Once ngAnimate is removed all works as advertised :) Any questions etc feel free

bealtine avatar Feb 15 '14 10:02 bealtine

http://plnkr.co/edit/YX7eKak2w8o7RFUhd5bd?p=preview

while 'ngAnimate' add in angular.module it doesn't work why?

wangqiang0323 avatar Feb 17 '14 09:02 wangqiang0323

Just letting everyone know here that ngAnimate is fixed up as best possible. Therefore the next step is to patch up ui-bootstrap so that the carousel can work both with and without ngAnimate properly.

matsko avatar Mar 01 '14 17:03 matsko

@matsko you are doing awesome job with this animation stuff! thnx for all the fixes and the info. Playing with other stuff right now but will test the latest version as soon as I've got some time.... Thnx once again!

pkozlowski-opensource avatar Mar 01 '14 18:03 pkozlowski-opensource

"Just letting everyone know here that ngAnimate is fixed up as best possible.
Therefore the next step is to patch up ui-bootstrap so that the carousel can
work both with and without ngAnimate properly."

Making sure I understand the current state of affairs. I cannot currently use the carousel component and ngAnimate in the same project? Is that right?

fogAndWhisky avatar Mar 19 '14 21:03 fogAndWhisky

@fogAndWhisky I haven't tested with the latest, have you tried? If it is not intergrated yet, the simple workaround I provided should still do the job.

iamlothian avatar Mar 19 '14 21:03 iamlothian

@iamlothian I apologize...I'm not seeing your workaround. Did you post under a different username?

fogAndWhisky avatar Mar 19 '14 21:03 fogAndWhisky

Oops mobile posted to early, will clean that up later. Yep sorry @autumn01 posted it.

iamlothian avatar Mar 19 '14 21:03 iamlothian

Ah, ok. Thanks. :) I will test the @autumn01 workaround with latest build and report back.

(Apologies to any watchers for spam posts).

fogAndWhisky avatar Mar 19 '14 21:03 fogAndWhisky