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>
This will be fixed soon through #1878 .
@chrisirhc Thanks. That's good to hear.
@iamlothian Yes, the @autumn01 fix works just fine for now. Thanks very much. For anyone else trying to shortcut this thread and just find the (current) answer: this directive enables/disables ngAnimate for an individual component:
.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>
Would someone mind testing this out using the snapshot build of AngularJS? There was a change in the class-based animations that removed the blocking feature. This may just fix the problem.
http://code.angularjs.org/snapshot/
@matsko , looks like you've solved it. Previously, the add animations were blocking each other. Now they're getting applied correctly as the transition only exists when both classes are active (I think).
EDIT: On reading your change further (https://github.com/angular/angular.js/commit/1bebe36aa938890d61188762ed618b1b5e193634), I think it's because it's no longer blocking and waiting for the -add and -remove classes to finish "animating" before addition/removal. Looks good. :+1:
Here are Plunkers with different builds.
Snapshot: http://plnkr.co/edit/cct3xQz0BhqBgirFIs4k?p=preview 1.2.15: http://plnkr.co/edit/hdnP6BOvhvjIrNm3gQUP?p=preview
updated my plunk above Still a few issues... I'll have a closer look at this later or early next week.
I've been holding back my angular-animate to 1.2.8 and this seemed to let ui bootstrap carousel work for a while. (In Firefox, its broken on Chrome though.) I noticed though, even while holding that back to 1.2.8, upgrading the core angular library from 1.2.12 to 1.2.13 breaks the carousel. (I even tried just using angular core 1.2.15 and angular-animate 1.2.15, also broken.)
Been looking at the changes from 1.2.12 to 1.2.13: https://github.com/angular/angular.js/compare/v1.2.12...v1.2.13#files_bucket
@linagee more than likely anything < 1.3-beta.4 won't fix the issue since the class-based animation fix was a breaking change. Have a go with the latest 1.3 snapshot.
matsko: I can verify that 1.3.0-beta-4 looks a lot more better than 1.2.15! Thanks.
To remove ngAnimate from a single directive, do as described here:
https://github.com/angular-ui/bootstrap/issues/1350#issuecomment-34595075
@leniel that issues is a duplication of this thread, and that solution was first proposed here 6 months ago.
@iamlothian Oh yes... TLDR; :smile: So that should be marked as duplicate, shouldn't it?
Hey guys. Is there anything else here that needs fixing in regards to ngAnimate?
@matsko thnx for keeping an eye on this one, much appreciated! For the moment I'm not sure what the problem is, I really haven't had too much time to spend on the carousel thing lately... But seems like recurring problem so let me have a closer look over the weekend.
@matsko @pkozlowski-opensource Here is an updated plunker using the latest versions: Angular "1.3.0-beta.5" and UI "0.11.0"
http://plnkr.co/edit/bY9nZIqvIkL4XybMe354?p=preview
It looks like the directive still fails to function normally without disabling angular animation an the element. I had to do this manually though as enabling it agin after the initial load using $animate.enabled(true, $element); doesn't work now.
Any ideas.
EDIT Via @leniel: updated bootstrap ui version to 0.11.0
@iamlothian isn't the latest version 0.11.0? http://angular-ui.github.io/bootstrap/
I just ran into this, too. https://github.com/angular-ui/bootstrap/issues/1350#issuecomment-34595075 provided a satisfactory workaround.
not sure if this is still live or not but the problem still exists with 1.3.0-beta.17 : http://plnkr.co/edit/DCzZ07jQxNO4GfqTf3aO?p=preview
Thanks...
Problem still exists. The height of the images is smaller then originally and the carousel slide distorts the images also...
problem still exists with all latests