Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Commit

Permalink
Changes to animation router and included an interrupt flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeanie Chung committed Feb 24, 2015
1 parent e79a5c1 commit e8f58a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
33 changes: 17 additions & 16 deletions js/angular/services/foundation.dynamicRouting.animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
function link(scope, element) {
var animation = {};
var initiator = false;
var animationEnded = false;
var presetHeight;

var cleanup = [
$rootScope.$on('$stateChangeStart', onStateChangeStart),
$rootScope.$on('$stateChangeError', onStateChangeError),
scope.$on('$stateChangeSuccess', onStateChangeSuccess),
scope.$on('$viewContentAnimationEnded', onViewContentAnimationEnded),
scope.$on('$viewContentAnimationEnded', onViewContentAnimationEnded)
];

var destroyed = scope.$on('$destroy', function onDestroy() {
Expand All @@ -39,29 +40,28 @@
});

function onStateChangeStart(event, toState, toParams, fromState, fromParams) {
if ($state.includes(getState()) && animation.leave) {
element.addClass(animation.leave);
}

animationRouter(event, toState, fromState);
if (fromState.animation) {
animationRouter(event, toState, fromState);
}

}

function animationRouter(event, toState, fromState) {
if (fromState.animation) {
if (!animationEnded) {
resetParent();

element.removeClass(fromState.animation.leave);

prepareParent();

if (fromState.animation.leave && !toState.animation.enter) {
// if there is already a state existing on the page
}
else {
prepareParent();

if (element.parent().children().length > 1) {
element.removeClass(fromState.animation.leave);
}
}
else {
prepareParent();
}
element.addClass(fromState.animation.leave);
}

}

function onStateChangeError() {
Expand All @@ -82,7 +82,8 @@
if (event.targetScope === scope && animation.enter) {
element.removeClass(animation.enter);
}
resetParent(); //reset parent if state change when animation is done

animationEnded = true;
}

function getState() {
Expand Down
2 changes: 1 addition & 1 deletion tests/motion/templates/out-only.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: out-only
url: /out-only
animationOut: slideInRight
animationOut: slideOutRight
---

<div style="background-color: #a4a02e; width: 100%;"></div>

0 comments on commit e8f58a2

Please sign in to comment.