Greetings,
I have been at this for a couple of hours now to no avail. I am trying to append some tweens to a timeline and use negative delays to offset them (they are the same animation otherwise).
My problem is that the timeline is waiting each to finish before restarting, which is what I do not want
Here's a link to what I have so far http://codepen.io/Zeaklous/pen/sGbku and my code:
var timeline = new TimelineMax({repeat:-1}),
electrons = document.querySelectorAll('.electron'),
paths = document.querySelectorAll('.path'),
atom = document.querySelectorAll('#atom'),
startDuration = 2;
for(var i = 0; i < electrons.length; i++) {
var myDelay = -(i * 0.5);
orbit(electrons[i], paths[i], myDelay);
}
function orbit(electron, path, delay) {
var e = TweenLite.to(electron, startDuration, {rotationY:'-360', ease:Linear.easeNone,
onComplete: function(){
//e.restart();
}, delay:delay
});
//timeline.append(e);
var p = TweenLite.to(path, startDuration, {rotationZ:'360', ease:Linear.easeNone,
onComplete: function(){
//p.restart();
}, delay:delay
});
//timeline.append(p);
// The following line doesn't seem to add a negative offset...
timeline.insertMultiple([e, p], 0, TweenAlign.START, -0.5);
}
atom.onmouseover = function() {
timeline.timeScale(.2);
}
function TweenAlign() {
}
If you look at the demo it runs correctly the first iteration (before it's added to the timeline) but fails the next times
Can you guys help me get this looking the way I'd like it to?
Thanks