When using ng-animate with ng-view, I want to use a function to change the animation.
For example:
Page
<div data-ng-view class="animate-container" ng-animate="animationSelect()"></div>
Controller
$scope.forward = true;
$scope.forwardAnimate = {enter: 'left-enter', leave: 'left-leave'}
$scope.backwardAnimate = {enter: 'right-enter', leave: 'right-leave'}
$scope.animationSelect = function() {
return $scope.forward ? $scope.forwardAnimate : $scope.backwardAnimate
}
If forward is true it animates one way, if it is false it animates a different way.
This approach doesn't seem to work. It appears that the animationSelect function is called only when the element is initially loaded. This is because the className is set at the start of the animateActionFactory function and then not updated on subsequent uses of the animation.
function animateActionFactory(type, beforeFn, afterFn) {
var ngAnimateValue = ngAnimateAttr && scope.$eval(ngAnimateAttr);
var className = ngAnimateAttr
? isObject(ngAnimateValue) ? ngAnimateValue[type] : ngAnimateValue + '-' + type
: '';
Further down a function is returned:
return function(element, parent, after) {
if (!$sniffer.supportsTransitions && !polyfillSetup && !polyfillStart) {
beforeFn(element, parent, after);
afterFn(element, parent, after);
return;
}
element.addClass(setupClass);
I am not sure if what I am trying to do is intended (or desired) functionality for angular's animation library. If it is, then moving the setting of the className into the function returned by animateActionFactory should solve the problem.
When using ng-animate with ng-view, I want to use a function to change the animation.
For example:
Page
Controller
If forward is true it animates one way, if it is false it animates a different way.
This approach doesn't seem to work. It appears that the animationSelect function is called only when the element is initially loaded. This is because the className is set at the start of the animateActionFactory function and then not updated on subsequent uses of the animation.
Further down a function is returned:
I am not sure if what I am trying to do is intended (or desired) functionality for angular's animation library. If it is, then moving the setting of the className into the function returned by animateActionFactory should solve the problem.