I am trying to create an animation which consists of a series of "steps" - the user hits the space bar to play through to the end of the "step," at which point they can hit the space bar to play the next "step" or navigate to any step via its label.
This codePen I found (http://codepen.io/frankrue/pen/XJJEQd) would be perfect, except that some of my steps have animations which should repeat continuously until the next step is started, and the addPause at the end of each scene prevents this. (For example, imagine a loading spinner or something continuously moving on the orange box that continues to move once the user hits 'continue' to bring in the yellow box)
My coworker and I created a "Stepper" abstraction that has a similar behavior to the codepen, but this has the same problem - stopping at the closeLabel means that any repeating animations which are supposed to keep repeating will stop.
Any thoughts?
Thanks!
var Stepper = (function() {
var
mainTimeline = new TimelineMax({ paused: true }),
steps = {},
stepOrder = [],
currentStepIndex = 0;
var closeLabel = function(base) { return base + 'End'; };
var appendStep = function(timeline, stepName) {
steps[stepName] = timeline;
stepOrder.push(stepName);
mainTimeline.add(stepName);
mainTimeline.add(timeline);
mainTimeline.add(closeLabel(stepName));
};
var playAt = function(stepName) {
currentStepIndex = _.indexOf(stepOrder, stepName);
mainTimeline.tweenFromTo(stepName, closeLabel(stepName));
};
var playNext = function() {
if(currentStepIndex < stepOrder.length - 1)
{
playAt(stepOrder[currentStepIndex + 1]);
}
};
return {
mainTimeline: mainTimeline,
steps: steps,
appendStep: appendStep,
playAt: playAt,
playNext: playNext
};
})();