From bef97f8972172b74066dff52542ef6998bb4ee8e Mon Sep 17 00:00:00 2001 From: Ulric Wilfred Date: Mon, 28 Dec 2015 15:49:47 +0100 Subject: [PATCH 1/2] use child band to calculate switch position --- src/anm/animation/element.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/anm/animation/element.js b/src/anm/animation/element.js index 320095d8..764d6f90 100644 --- a/src/anm/animation/element.js +++ b/src/anm/animation/element.js @@ -712,11 +712,11 @@ 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); + //console.log('switch band', this.switchBand, 'child', child.name, 'child duration', child.timeline.getDuration(), 't', this.getTime(), 'calculated child t', newPos, 'result child t', childTime); 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 { From 9ae3796ecfc518d3ae10d8403d40e8e1f7565d8b Mon Sep 17 00:00:00 2001 From: Ulric Wilfred Date: Mon, 28 Dec 2015 15:51:14 +0100 Subject: [PATCH 2/2] remove loging from switcher code --- src/anm/animation/element.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/anm/animation/element.js b/src/anm/animation/element.js index 764d6f90..882f0d43 100644 --- a/src/anm/animation/element.js +++ b/src/anm/animation/element.js @@ -715,7 +715,6 @@ Element.prototype.tick = function(dt) { if (this.justSwitched) child.timeline.reset(); var newPos = (this.getTime() - this.switchBand[0]) % child.timeline.getDuration(); var childTime = child.timeline.tickRelativeToPosition(newPos, dt); - //console.log('switch band', this.switchBand, 'child', child.name, 'child duration', child.timeline.getDuration(), 't', this.getTime(), 'calculated child t', newPos, 'result child t', childTime); if (child.timeline.isActive()) child.modifiers(childTime, dt); } }.bind(this));