ui bootstrap carousel animation angular 1.2.* issues
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>
@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
Try out 1.2.9 later today since there are a few class-based animation fixes in there.
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
I lost the whole morning on this. @autumn01 Thanks a lot, we'll use your solution until fix is made.
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 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!
Modal show/hide is broken with ngAnimate as well -- the 'in' class never gets added/removed.
@alalonde Until we reach the next version, ngAnimate won't help that much. We are now in the middle of supporting it.
This is in a PR at the moment: https://github.com/angular/angular.js/pull/6267
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 can you provide a plunkr?
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
http://plnkr.co/edit/YX7eKak2w8o7RFUhd5bd?p=preview
while 'ngAnimate' add in angular.module it doesn't work why?
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 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!
"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 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 I apologize...I'm not seeing your workaround. Did you post under a different username?
Oops mobile posted to early, will clean that up later. Yep sorry @autumn01 posted it.
Ah, ok. Thanks. :) I will test the @autumn01 workaround with latest build and report back.
(Apologies to any watchers for spam posts).