Conditional Animation for AngularJS -
trying conditional animation work. method works 2 classes (left , right) gets weird 3 classes.(sometimes fade, use left/right) gets unwieldy more classes. tips?
i have whatever want animate (in case ng-view) these classes defined.
ng-class="{animateleft: goingleft, animateright: goingright, fadein: fading}"
i add these functions ng-click() on navigation buttons.
$scope.goright = function(){ $scope.goingright = true; $scope.goingleft = false; $scope.fading = false; }; $scope.goleft = function(){ $scope.goingright = false; $scope.goingleft = true; $scope.fading = false; }; $scope.fadein = function(){ $scope.goingright = false; $scope.goingleft = false; $scope.fading = true; };
i figured out being weird. method work. need understand how angular animates things step step.
to animate in angular assign 4 css classes.
1)the state should start in when enters. (e.g. off side , invisible)
2)the state should end in when enters. (e.g. going middle , visible)
3)the state should start in when exits. (e.g. start middle , visible)
4)the state should end in when exits. (e.g. go side , invisible)
this means there 2 objects on "stage" same time animation occurring (one leaving while other entering). when object enters stage, it's programmed leave in way. when other objects comes onto stage, objects leaves.
my problem wanted view conditionally leave conditionally enter. call enter animation because leave conditional set before knowing how i'd call enter way leaves cannot changed.
i changed code pages animate stage based on condition (e.g. animate in arrow direction click) made them fade 0 on leave instead of leave in opposite direction. animations weird because click on right, page animate in right, when wanted fade page previous page leave left confusing.
just remember page animating both enter , leave classes set when call it.
Comments
Post a Comment