diff --git a/src/anm/animation/element.js b/src/anm/animation/element.js index 320095d8..882f0d43 100644 --- a/src/anm/animation/element.js +++ b/src/anm/animation/element.js @@ -712,11 +712,10 @@ Element.prototype.tick = function(dt) { if (this.hasSwitch) { this.each(function(child) { if (child.name == this.switch) { - if (this.justSwitched/* || ((this.getTime() - this.switchBand[0]) > child.timeline.getDuration())*/) child.timeline.reset(); - //console.log('before', this.switchBand, 'parent', this.name, this.getTime(), 'child', child.name, child.getTime(), 'dt', dt); - var childTime = child.timeline.tickRelativeToPosition(this.getTime() - this.switchBand[0], dt); + if (this.justSwitched) child.timeline.reset(); + var newPos = (this.getTime() - this.switchBand[0]) % child.timeline.getDuration(); + var childTime = child.timeline.tickRelativeToPosition(newPos, dt); if (child.timeline.isActive()) child.modifiers(childTime, dt); - //console.log('after', this.switchBand, 'parent', this.name, this.getTime(), 'child', child.name, child.getTime(), 'dt', dt); } }.bind(this)); } else {