2

I working on a multi-stage-web-form with AngularJS, as you can see at the following example:

http://codepen.io/kwakwak/full/kvEig

When you click the "Next" button, the form slides right, but when you click the "Back" button, the form isn't slides left as it should, I need to change the "ng-animate" css when the "Back" button is clicked.

How should I accomplish that ?

Thanks !

1 Answer 1

8

In your controller you can set a variable that determines the direction of the animation.. So something like this (pseudocode):

$scope.update = function() {
   $scope.direction = 1;
}

$scope.backTo = function() {
   $scope.direction = 0;
}

In your html you'd surround the areas that are animating:

<div ng-class="{forward: direction, backward: !direction}">
   your animated stuff here
</div>

Now just setup your css rules:

.forward .animate-switch.ng-leave{  
  left:0;
}
/* hide */
.forward  .animate-switch.ng-leave.ng-leave-active{ 
  left:-100%;
}
/* show entering slide  */
/* hide */
.forward .animate-switch.ng-enter {
  left:100%;
}
/* show */
.forward .animate-switch.ng-enter.ng-enter-active { 
  left:0;
}

.backward  animate-switch.ng-leave{  
  /* etc */
}

Here is a demo from your code pen: http://codepen.io/sbosell/pen/rKJal

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.