Skip to content

Commit

Permalink
Fixed manageNavigationSkip now .seq-in and .seq-out can have independ…
Browse files Browse the repository at this point in the history
…ent durations and delays
  • Loading branch information
IanLunn committed May 1, 2015
1 parent ed301a9 commit e1bd69f
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 65 deletions.
63 changes: 35 additions & 28 deletions scripts/sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -1472,28 +1472,32 @@ function defineSequence(imagesLoaded, Hammer) {
currentPhaseProperties,
currentPhaseDuration,
phaseThresholdTime,
activePhases = {};
activePhases;

if (self.firstRun === false) {

// Callback
animation.currentPhaseStarted();
animation.currentPhaseStarted(self.currentStepId);
}

// Snap the step to the "animate-start" phase
removeClass(nextStepElement, "seq-out");

animation.domDelay(function() {

// Make the activePhases public
// self.stepProperties.activePhases = activePhases;

// Make the current step transition to "seq-out"
currentPhaseProperties = animation.startAnimateOut(self.prevStepId, currentStepElement, 1);

// How long will the current watched elements animate for (including delay)?
currentPhaseDuration = currentPhaseProperties.watchedTimings.maxTotal;

activePhases = self.stepProperties.activePhases = {
"current": currentPhaseProperties,
"next": {
"stepElement": nextStepElement
}
};

// Determine how often goTo() can be used based on
// navigationSkipThreshold and manage step fading accordingly
self.animation.manageNavigationSkip(id, 1, nextStepElement, activePhases);
Expand Down Expand Up @@ -1535,15 +1539,17 @@ function defineSequence(imagesLoaded, Hammer) {

animation.domDelay(function() {

// Make the activePhases public
// self.stepProperties.activePhases = activePhases;

// Get the step number, element, its animated elements (child nodes), and
// max timings
currentPhaseProperties = animation.getPhaseProperties(self.prevStepId, "current");
currentPhaseProperties = animation.getPhaseProperties(self.currentStepId, "current");

nextPhaseProperties = animation.getPhaseProperties(id, "next");

activePhases = self.stepProperties.activePhases = {
"current": currentPhaseProperties,
"next": nextPhaseProperties
};

// Add a threshold between delays if one finishes before another when
// navigating forwards
reversePhaseThreshold = animation.getReversePhaseThreshold(self.options.phaseThreshold, currentPhaseProperties.timings.maxTotal, nextPhaseProperties.timings.maxTotal);
Expand Down Expand Up @@ -1597,7 +1603,7 @@ function defineSequence(imagesLoaded, Hammer) {
current = 0,
next = 0;

if (phaseThresholdOption !== true) {
// if (phaseThresholdOption !== true) {

phaseDifference = currentPhaseDuration - nextPhaseDuration;

Expand All @@ -1606,7 +1612,7 @@ function defineSequence(imagesLoaded, Hammer) {
} else if (phaseDifference < 0) {
current = Math.abs(phaseDifference);
}
}
// }

return {
next: next,
Expand All @@ -1632,6 +1638,15 @@ function defineSequence(imagesLoaded, Hammer) {
nextPhaseProperties,
nextPhaseStarts = phaseThresholdTime;

// The next ID is now the current ID
self.prevStepId = self.currentStepId;
self.currentStepId = id;

if (self.firstRun === true) {
// Update pagination
self.pagination.update();
}

// When should the "seq-in" phase start and how long until the step
// completely finishes animating?
if (self.firstRun === false || self.options.startingStepAnimatesIn === true) {
Expand Down Expand Up @@ -1799,13 +1814,14 @@ function defineSequence(imagesLoaded, Hammer) {
/**
* When the current phase starts animating
*/
currentPhaseStarted: function() {
currentPhaseStarted: function(id) {

// Callback
self.currentPhaseStarted(self.prevStepId, self);
if (id === undefined) {
id = self.prevStepId;
}

// Update pagination
self.pagination.update();
// Callback
self.currentPhaseStarted(id, self);
},

/**
Expand Down Expand Up @@ -1833,6 +1849,9 @@ function defineSequence(imagesLoaded, Hammer) {
self.hashTags.update();
}

// Update pagination
self.pagination.update();

// Callback
self.nextPhaseStarted(self.currentStepId, self);
},
Expand Down Expand Up @@ -1902,8 +1921,6 @@ function defineSequence(imagesLoaded, Hammer) {
*/
stepEnded: function(id) {

// self.stepEndedTimer = setTimeout(function() {

self.isAnimating = false;
self.isAutoPlaying = false;

Expand All @@ -1914,7 +1931,6 @@ function defineSequence(imagesLoaded, Hammer) {

// Callback
self.animationEnded(id, self);
// }, stepDuration);
},

/**
Expand Down Expand Up @@ -3832,15 +3848,6 @@ function defineSequence(imagesLoaded, Hammer) {
self.animationStarted(id, self);
}

// The next ID is now the current ID
self.prevStepId = self.currentStepId;
self.currentStepId = id;

// Should the phaseThreshold be ignored?
if (self.isAnimating === true) {
ignorePhaseThreshold = true;
}

// Sequence is now animating
self.isAnimating = true;

Expand Down
4 changes: 2 additions & 2 deletions scripts/sequence.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/sequence.min.map

Large diffs are not rendered by default.

63 changes: 35 additions & 28 deletions src/sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -1472,28 +1472,32 @@ function defineSequence(imagesLoaded, Hammer) {
currentPhaseProperties,
currentPhaseDuration,
phaseThresholdTime,
activePhases = {};
activePhases;

if (self.firstRun === false) {

// Callback
animation.currentPhaseStarted();
animation.currentPhaseStarted(self.currentStepId);
}

// Snap the step to the "animate-start" phase
removeClass(nextStepElement, "seq-out");

animation.domDelay(function() {

// Make the activePhases public
// self.stepProperties.activePhases = activePhases;

// Make the current step transition to "seq-out"
currentPhaseProperties = animation.startAnimateOut(self.prevStepId, currentStepElement, 1);

// How long will the current watched elements animate for (including delay)?
currentPhaseDuration = currentPhaseProperties.watchedTimings.maxTotal;

activePhases = self.stepProperties.activePhases = {
"current": currentPhaseProperties,
"next": {
"stepElement": nextStepElement
}
};

// Determine how often goTo() can be used based on
// navigationSkipThreshold and manage step fading accordingly
self.animation.manageNavigationSkip(id, 1, nextStepElement, activePhases);
Expand Down Expand Up @@ -1535,15 +1539,17 @@ function defineSequence(imagesLoaded, Hammer) {

animation.domDelay(function() {

// Make the activePhases public
// self.stepProperties.activePhases = activePhases;

// Get the step number, element, its animated elements (child nodes), and
// max timings
currentPhaseProperties = animation.getPhaseProperties(self.prevStepId, "current");
currentPhaseProperties = animation.getPhaseProperties(self.currentStepId, "current");

nextPhaseProperties = animation.getPhaseProperties(id, "next");

activePhases = self.stepProperties.activePhases = {
"current": currentPhaseProperties,
"next": nextPhaseProperties
};

// Add a threshold between delays if one finishes before another when
// navigating forwards
reversePhaseThreshold = animation.getReversePhaseThreshold(self.options.phaseThreshold, currentPhaseProperties.timings.maxTotal, nextPhaseProperties.timings.maxTotal);
Expand Down Expand Up @@ -1597,7 +1603,7 @@ function defineSequence(imagesLoaded, Hammer) {
current = 0,
next = 0;

if (phaseThresholdOption !== true) {
// if (phaseThresholdOption !== true) {

phaseDifference = currentPhaseDuration - nextPhaseDuration;

Expand All @@ -1606,7 +1612,7 @@ function defineSequence(imagesLoaded, Hammer) {
} else if (phaseDifference < 0) {
current = Math.abs(phaseDifference);
}
}
// }

return {
next: next,
Expand All @@ -1632,6 +1638,15 @@ function defineSequence(imagesLoaded, Hammer) {
nextPhaseProperties,
nextPhaseStarts = phaseThresholdTime;

// The next ID is now the current ID
self.prevStepId = self.currentStepId;
self.currentStepId = id;

if (self.firstRun === true) {
// Update pagination
self.pagination.update();
}

// When should the "seq-in" phase start and how long until the step
// completely finishes animating?
if (self.firstRun === false || self.options.startingStepAnimatesIn === true) {
Expand Down Expand Up @@ -1799,13 +1814,14 @@ function defineSequence(imagesLoaded, Hammer) {
/**
* When the current phase starts animating
*/
currentPhaseStarted: function() {
currentPhaseStarted: function(id) {

// Callback
self.currentPhaseStarted(self.prevStepId, self);
if (id === undefined) {
id = self.prevStepId;
}

// Update pagination
self.pagination.update();
// Callback
self.currentPhaseStarted(id, self);
},

/**
Expand Down Expand Up @@ -1833,6 +1849,9 @@ function defineSequence(imagesLoaded, Hammer) {
self.hashTags.update();
}

// Update pagination
self.pagination.update();

// Callback
self.nextPhaseStarted(self.currentStepId, self);
},
Expand Down Expand Up @@ -1902,8 +1921,6 @@ function defineSequence(imagesLoaded, Hammer) {
*/
stepEnded: function(id) {

// self.stepEndedTimer = setTimeout(function() {

self.isAnimating = false;
self.isAutoPlaying = false;

Expand All @@ -1914,7 +1931,6 @@ function defineSequence(imagesLoaded, Hammer) {

// Callback
self.animationEnded(id, self);
// }, stepDuration);
},

/**
Expand Down Expand Up @@ -3832,15 +3848,6 @@ function defineSequence(imagesLoaded, Hammer) {
self.animationStarted(id, self);
}

// The next ID is now the current ID
self.prevStepId = self.currentStepId;
self.currentStepId = id;

// Should the phaseThreshold be ignored?
if (self.isAnimating === true) {
ignorePhaseThreshold = true;
}

// Sequence is now animating
self.isAnimating = true;

Expand Down
5 changes: 3 additions & 2 deletions tests/themes/test-theme/css/sequence-theme.test-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#sequence .boxb {
top: 200px;
/*transition-duration: 2s;*/
transition-duration: 2s;
/*transition-delay: .5s;*/
}

Expand All @@ -68,7 +68,8 @@
margin-left: -50px;
-webkit-transition-duration: 1s;
transition-duration: 1s;
/*transition-delay: 2s;*/
/*-webkit-transition-delay: .5s;*/
/*transition-delay: .5s;*/


}
Expand Down
10 changes: 6 additions & 4 deletions tests/themes/test-theme/scripts/sequence-theme.test-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ var options = {
autoPlay: false,
autoPlayDirection: -1,
autoPlayDelay: 1000,
phaseThreshold: 500,
phaseThreshold: true,
// preloader: true,
keyNavigation: true,
// hashTags: true,
startingStepId: 1,
// startingStepAnimatesIn: true,
reverseWhenNavigatingBackwards: true
reverseWhenNavigatingBackwards: true,
navigationSkip: true,
fadeStepWhenSkipped: true
}

var mySequence,
Expand Down Expand Up @@ -82,9 +84,9 @@ mySequence.nextPhaseEnded = function(id) {
}

mySequence.animationStarted = function(id) {
console.log("started", id);
// console.log("started", id);
};

mySequence.animationEnded = function(id) {
console.log("ended", id);
// console.log("ended", id);
};

0 comments on commit e1bd69f

Please sign in to comment.