Skip to content

Commit d271596

Browse files
committed
Separated position calculations for use by MovieClip.
Signed-off-by: Grant Skinner <info@gskinner.com>
1 parent 86a3b67 commit d271596

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/tweenjs/Timeline.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ this.createjs = this.createjs||{};
339339
* is `false`).
340340
**/
341341
p.setPosition = function(value, actionsMode) {
342-
if (value < 0) { value = 0; }
343-
var t = this.loop ? value%this.duration : value;
342+
var t = this._calcPosition(value);
344343
var end = !this.loop && value >= this.duration;
345344
if (t == this._prevPos) { return end; }
346345
this._prevPosition = value;
@@ -420,13 +419,25 @@ this.createjs = this.createjs||{};
420419
// private methods:
421420
/**
422421
* @method _goto
422+
* @param {String | Number} positionOrLabel
423423
* @protected
424424
**/
425425
p._goto = function(positionOrLabel) {
426426
var pos = this.resolve(positionOrLabel);
427427
if (pos != null) { this.setPosition(pos); }
428428
};
429-
429+
430+
/**
431+
* @method _calcPosition
432+
* @param {Number} value
433+
* @return {Number}
434+
* @protected
435+
**/
436+
p._calcPosition = function(value) {
437+
if (value < 0) { return 0; }
438+
if (value < this.duration) { return value; }
439+
return this.loop ? value%this.duration : this.duration;
440+
};
430441

431442
createjs.Timeline = createjs.promote(Timeline, "EventDispatcher");
432443

0 commit comments

Comments
 (0)