Created
October 22, 2010 09:48
-
-
Save casparkleijne/640258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var CasparKleijne = {}; | |
CasparKleijne.Core = {}; | |
CasparKleijne.Canvas = {}; | |
CasparKleijne.Canvas.GFX = {}; | |
(CasparKleijne.Core.TimeLineManager = function (s) { | |
var a, | |
p = 0, /** isPlaying status **/ | |
f = 0, /** frame index **/ | |
max = s.frames.length, | |
moveNext, /** public method **/ | |
start, /** public method **/ | |
stop, /** public method **/ | |
reset; /** public method **/ | |
p = false; /** there are no events fired **/ | |
setInterval(function () { | |
if (p) { | |
callBack(s.frames[f]); | |
callBack(s.onFrame); | |
moveNext(); | |
} | |
}, | |
s.ticks | |
); | |
moveNext = function () { | |
f = f >= max - 1 ? 0 : f + 1; | |
p = f === 0 ? s.loop : p; | |
}; | |
/** starts firering events from the interval method **/ | |
callBack = function (e) { | |
if (e !== undefined) { | |
e({ | |
currentTarget: this, | |
frame : f | |
}); | |
} | |
}; | |
/** starts firering events from the interval method **/ | |
start = function () { | |
callBack(s.onStart); | |
p = true; | |
}; | |
/** stops firering events from the interval method **/ | |
stop = function () { | |
callBack(s.onStop); | |
p = false; | |
}; | |
/** resets firering events from the interval method **/ | |
reset = function () { | |
callBack(s.onReset); | |
f = 0; | |
stop(); | |
}; | |
return { | |
start: start, | |
stop: stop, | |
reset: reset | |
}; | |
}); | |
var t$ = []; | |
t$[0] = function (e) { | |
console.log("FRAME 1 " + e.frame + "/"); | |
}; | |
t$[1] = function (e) { | |
console.log("FRAME 2 " + e.frame + "/"); | |
}; | |
t$[22] = function (e) { | |
console.log("FRAME 3 " + e.frame + "/"); | |
}; | |
t$[4] = function (e) { | |
console.log("FRAME 5 " + e.frame + "/"); | |
}; | |
var timelineManager = CasparKleijne.Core.TimeLineManager({ | |
ticks: 333, | |
frames: t$, | |
loop: true, | |
onFrame: function (e) { | |
//console.log(e.frame + "/"); | |
} | |
}); | |
timelineManager.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment