mover.clone().insertAfter(mover)
canvas.line(100, 300, 800, 300).attr('stroke', 'black')
-// t.on('time', function (e) {
-// mover.x(100 + e.detail/10)
-// })
+t.on('time', function (e) {
+ mover.x(100 + e.detail/10)
+})
console.log(schedule)
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Tue Nov 20 2018 16:59:18 GMT+0100 (GMT+01:00)
+* BUILT: Wed Nov 21 2018 10:58:56 GMT+0100 (GMT+01:00)
*/;
var SVG = (function () {
'use strict';
};
};
+ var defaultSource = function defaultSource() {
+ var w = globals.window;
+ return (w.performance || w.Date).now();
+ };
+
var Timeline =
/*#__PURE__*/
function (_EventTarget) {
function Timeline() {
var _this;
+ var timeSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSource;
+
_classCallCheck(this, Timeline);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Timeline).call(this));
-
- _this._timeSource = function () {
- var w = globals.window;
- return (w.performance || w.Date).now();
- }; // Store the timing variables
-
+ _this._timeSource = timeSource; // Store the timing variables
_this._startTime = 0;
_this._speed = 1.0; // Play control variables control how the animation proceeds
_this._lastSourceTime = 0;
_this._lastStepTime = 0;
return _this;
- }
- /**
- *
- */
- // schedules a runner on the timeline
+ } // schedules a runner on the timeline
_createClass(Timeline, [{
key: "schedule",
value: function 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.runner.id - b.runner.id; // return (a.start - b.start) || (a.duration - b.duration)
+ return a.runner.id - b.runner.id;
});
}
if (runnersLeft) {
this._nextFrame = Animator.frame(this._step.bind(this));
} else {
+ this.fire('finished');
this._nextFrame = null;
}
return { start: start, duration: duration, end: end, runner: runnerInfo.runner }
}
+const defaultSource = function () {
+ let w = globals.window
+ return (w.performance || w.Date).now()
+}
+
export default class Timeline extends EventTarget {
// Construct a new timeline on the given element
- constructor () {
+ constructor (timeSource = defaultSource) {
super()
- this._timeSource = function () {
- let w = globals.window
- return (w.performance || w.Date).now()
- }
+ this._timeSource = timeSource
// Store the timing variables
this._startTime = 0