Skip to content

Commit 88e62d3

Browse files
author
Lanny McNie
committedMay 27, 2015
Added NEXT libs and docs
1 parent f6a3c5e commit 88e62d3

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed
 

‎docs/TweenJS_docs-NEXT.zip

894 Bytes
Binary file not shown.

‎lib/tweenjs-NEXT.combined.js

+41-11
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,15 @@ this.createjs = this.createjs||{};
15611561
* @protected
15621562
*/
15631563
this._inited = false;
1564+
1565+
/**
1566+
* Indicates whether the tween is currently registered with Tween.
1567+
* @property _registered
1568+
* @type {boolean}
1569+
* @default false
1570+
* @protected
1571+
*/
1572+
this._registered = false;
15641573

15651574

15661575
if (props) {
@@ -1738,7 +1747,7 @@ this.createjs = this.createjs||{};
17381747
for (var i= 0, l=tweens.length; i<l; i++) {
17391748
var tween = tweens[i];
17401749
tween._paused = true;
1741-
tween.target.tweenjs_count = 0;
1750+
tween.target&&(tween.target.tweenjs_count = 0);
17421751
}
17431752
tweens.length = 0;
17441753
};
@@ -1752,7 +1761,7 @@ this.createjs = this.createjs||{};
17521761
* @static
17531762
*/
17541763
Tween.hasActiveTweens = function(target) {
1755-
if (target) { return target.tweenjs_count; }
1764+
if (target) { return target.tweenjs_count != null && !!target.tweenjs_count; }
17561765
return Tween._tweens && !!Tween._tweens.length;
17571766
};
17581767

@@ -1791,21 +1800,22 @@ this.createjs = this.createjs||{};
17911800
Tween._register = function(tween, value) {
17921801
var target = tween._target;
17931802
var tweens = Tween._tweens;
1794-
if (value) {
1803+
if (value && !tween._registered) {
17951804
// TODO: this approach might fail if a dev is using sealed objects in ES5
17961805
if (target) { target.tweenjs_count = target.tweenjs_count ? target.tweenjs_count+1 : 1; }
17971806
tweens.push(tween);
17981807
if (!Tween._inited && createjs.Ticker) { createjs.Ticker.addEventListener("tick", Tween); Tween._inited = true; }
1799-
} else {
1808+
} else if (!value && tween._registered) {
18001809
if (target) { target.tweenjs_count--; }
18011810
var i = tweens.length;
18021811
while (i--) {
18031812
if (tweens[i] == tween) {
18041813
tweens.splice(i, 1);
1805-
return;
1814+
break;
18061815
}
18071816
}
18081817
}
1818+
tween._registered = value;
18091819
};
18101820

18111821

@@ -1913,7 +1923,7 @@ this.createjs = this.createjs||{};
19131923
/**
19141924
* Queues an action to pause the specified tween.
19151925
* @method pause
1916-
* @param {Tween} tween The tween to play. If null, it pauses this tween.
1926+
* @param {Tween} tween The tween to pause. If null, it pauses this tween.
19171927
* @return {Tween} This tween instance (for chaining calls)
19181928
*/
19191929
p.pause = function(tween) {
@@ -2329,6 +2339,15 @@ this.createjs = this.createjs||{};
23292339
* @protected
23302340
**/
23312341
this._useTicks = false;
2342+
2343+
/**
2344+
* Indicates whether the timeline is currently registered with Tween.
2345+
* @property _registered
2346+
* @type {boolean}
2347+
* @default false
2348+
* @protected
2349+
*/
2350+
this._registered = false;
23322351

23332352

23342353
if (props) {
@@ -2508,8 +2527,7 @@ this.createjs = this.createjs||{};
25082527
* is `false`).
25092528
**/
25102529
p.setPosition = function(value, actionsMode) {
2511-
if (value < 0) { value = 0; }
2512-
var t = this.loop ? value%this.duration : value;
2530+
var t = this._calcPosition(value);
25132531
var end = !this.loop && value >= this.duration;
25142532
if (t == this._prevPos) { return end; }
25152533
this._prevPosition = value;
@@ -2529,7 +2547,7 @@ this.createjs = this.createjs||{};
25292547
* @param {Boolean} value Indicates whether the tween should be paused (`true`) or played (`false`).
25302548
**/
25312549
p.setPaused = function(value) {
2532-
this._paused = !!value;
2550+
this._paused = !!value;
25332551
createjs.Tween._register(this, !value);
25342552
};
25352553

@@ -2589,13 +2607,25 @@ this.createjs = this.createjs||{};
25892607
// private methods:
25902608
/**
25912609
* @method _goto
2610+
* @param {String | Number} positionOrLabel
25922611
* @protected
25932612
**/
25942613
p._goto = function(positionOrLabel) {
25952614
var pos = this.resolve(positionOrLabel);
25962615
if (pos != null) { this.setPosition(pos); }
25972616
};
2598-
2617+
2618+
/**
2619+
* @method _calcPosition
2620+
* @param {Number} value
2621+
* @return {Number}
2622+
* @protected
2623+
**/
2624+
p._calcPosition = function(value) {
2625+
if (value < 0) { return 0; }
2626+
if (value < this.duration) { return value; }
2627+
return this.loop ? value%this.duration : this.duration;
2628+
};
25992629

26002630
createjs.Timeline = createjs.promote(Timeline, "EventDispatcher");
26012631

@@ -3368,6 +3398,6 @@ this.createjs = this.createjs || {};
33683398
* @type String
33693399
* @static
33703400
**/
3371-
s.buildDate = /*=date*/"Thu, 12 Mar 2015 20:31:51 GMT"; // injected by build process
3401+
s.buildDate = /*=date*/"Wed, 27 May 2015 18:12:44 GMT"; // injected by build process
33723402

33733403
})();

0 commit comments

Comments
 (0)