summaryrefslogtreecommitdiffstats
path: root/src/animation/Timeline.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/animation/Timeline.js')
-rw-r--r--src/animation/Timeline.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js
index f1d540a..6abcb80 100644
--- a/src/animation/Timeline.js
+++ b/src/animation/Timeline.js
@@ -1,8 +1,7 @@
+import { globals } from '../utils/window.js'
import { registerMethods } from '../utils/methods.js'
import Animator from './Animator.js'
-import { globals } from '../utils/window.js'
-
-var time = globals.window.performance || Date
+import EventTarget from '../types/EventTarget.js'
var makeSchedule = function (runnerInfo) {
var start = runnerInfo.start
@@ -11,15 +10,16 @@ var makeSchedule = function (runnerInfo) {
return { start: start, duration: duration, end: end, runner: runnerInfo.runner }
}
-export default class Timeline {
+export default class Timeline extends EventTarget {
// Construct a new timeline on the given element
constructor () {
+ super()
+
this._timeSource = function () {
- return time.now()
+ let w = globals.window
+ return (w.performance || w.Date).now()
}
- this._dispatcher = globals.document.createElement('div')
-
// Store the timing variables
this._startTime = 0
this._speed = 1.0
@@ -38,16 +38,13 @@ export default class Timeline {
this._lastStepTime = 0
}
- getEventTarget () {
- return this._dispatcher
- }
-
/**
*
*/
// schedules a runner on the timeline
schedule (runner, delay, when) {
+ // FIXME: how to sort? maybe by runner id?
if (runner == null) {
return this._runners.map(makeSchedule).sort(function (a, b) {
return (a.start - b.start) || (a.duration - b.duration)