diff options
-rw-r--r-- | dirty.html | 6 | ||||
-rw-r--r-- | dist/svg.js | 26 | ||||
-rw-r--r-- | src/animation/Timeline.js | 12 |
3 files changed, 22 insertions, 22 deletions
@@ -135,9 +135,9 @@ var mover = canvas.line(100, 100, 100, 300).attr('stroke', 'black') 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) diff --git a/dist/svg.js b/dist/svg.js index 6abe275..9d7a861 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @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'; @@ -5010,6 +5010,11 @@ var SVG = (function () { }; }; + var defaultSource = function defaultSource() { + var w = globals.window; + return (w.performance || w.Date).now(); + }; + var Timeline = /*#__PURE__*/ function (_EventTarget) { @@ -5019,15 +5024,12 @@ var SVG = (function () { 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 @@ -5043,20 +5045,15 @@ var SVG = (function () { _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; }); } @@ -5256,6 +5253,7 @@ var SVG = (function () { if (runnersLeft) { this._nextFrame = Animator.frame(this._step.bind(this)); } else { + this.fire('finished'); this._nextFrame = null; } diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js index 6e1ed8d..a0d8069 100644 --- a/src/animation/Timeline.js +++ b/src/animation/Timeline.js @@ -10,15 +10,17 @@ var makeSchedule = function (runnerInfo) { 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 |