Skip to content

Commit 171bfe1

Browse files
committed
Added Timeline.getCurrentLabel();
Signed-off-by: Grant Skinner <info@gskinner.com>
1 parent b23c805 commit 171bfe1

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

VERSIONS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CRITICAL (may break existing content):
2020
- Added "use strict"; to everything.
2121
- fixed an issue with EventDispatcher when adding the same listener to an event twice
2222
- fixed hasActiveTweens to return a Boolean consistently
23-
- added Timeline.getLabels()
23+
- added Timeline.getLabels() & getCurrentLabel()
2424

2525

2626
Version 0.4.1 [May 10, 2013]

docs/TweenJS_docs-NEXT.zip

591 Bytes
Binary file not shown.

lib/tweenjs-NEXT.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tweenjs/Timeline.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,27 @@ var p = Timeline.prototype;
288288
return list;
289289
};
290290

291-
291+
/**
292+
* Returns the name of the label on or immediately before the current position. For example, given a timeline with
293+
* two labels, "first" on frame index 4, and "second" on frame 8, getCurrentLabel would return:<UL>
294+
* <LI>null if the current position is 2.</LI>
295+
* <LI>"first" if the current position is 4.</LI>
296+
* <LI>"first" if the current position is 7.</LI>
297+
* <LI>"second" if the current position is 15.</LI></UL>
298+
* @method getCurrentLabel
299+
* @return {String} The name of the current label or null if there is no label
300+
**/
301+
p.getCurrentLabel = function() {
302+
var labels = this.getLabels();
303+
var pos = this.position;
304+
var l = labels.length;
305+
if (l) {
306+
for (var i = 0; i<l; i++) { if (pos < labels[i].position) { break; } }
307+
return (i==0) ? null : labels[i-1].label;
308+
}
309+
return null;
310+
};
311+
292312
/**
293313
* Unpauses this timeline and jumps to the specified position or label.
294314
* @method gotoAndPlay

src/tweenjs/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ this.createjs = this.createjs || {};
2727
* @type String
2828
* @static
2929
**/
30-
s.buildDate = /*date*/"Thu, 08 Aug 2013 05:15:28 GMT"; // injected by build process
30+
s.buildDate = /*date*/"Mon, 12 Aug 2013 16:06:01 GMT"; // injected by build process
3131

3232
})();

0 commit comments

Comments
 (0)