summaryrefslogtreecommitdiff
path: root/new-reality/public/assets/js/grid/timeline.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-11-29 22:44:58 -0500
committerJules Laplace <jules@okfoc.us>2016-11-29 22:44:58 -0500
commitcf08a9dab5d27e6d3fb76e169f679446f03f1055 (patch)
tree9c26dfa319a144baae34e9d23a365360626475b5 /new-reality/public/assets/js/grid/timeline.js
parentf4215bbc1a602ab19172950a29fc8ad5504b93fb (diff)
pull in holodeck
Diffstat (limited to 'new-reality/public/assets/js/grid/timeline.js')
-rw-r--r--new-reality/public/assets/js/grid/timeline.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/new-reality/public/assets/js/grid/timeline.js b/new-reality/public/assets/js/grid/timeline.js
new file mode 100644
index 0000000..651e315
--- /dev/null
+++ b/new-reality/public/assets/js/grid/timeline.js
@@ -0,0 +1,21 @@
+function Timeline (tweens) {
+ this.tweens = tweens
+ this.index = 0
+}
+Timeline.prototype.advance = function(){
+ var tl = this.tweens[this.index % this.tweens.length]
+ if (tl.index == -1) {
+ tl.reset()
+ tl.index = 0
+ requestAnimationFrame(this.advance.bind(this))
+ }
+ else if (tl.index < tl.timeline.length){
+ tl.timeline[ tl.index ](this.advance.bind(this))
+ tl.index += 1
+ }
+ else {
+ this.index += 1
+ tl.index = -1
+ requestAnimationFrame(this.advance.bind(this))
+ }
+}