From 8db39b099ea85d881f5e4d12b2b2182d41414da4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Sat, 13 Oct 2018 00:49:35 +0200 Subject: [PATCH] fix timeline timing with runners --- src/timeline.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/timeline.js b/src/timeline.js index c0b0a99..02de178 100644 --- a/src/timeline.js +++ b/src/timeline.js @@ -20,10 +20,7 @@ SVG.Timeline = SVG.invent({ inherit: SVG.EventTarget, // Construct a new timeline on the given element - create: function (element) { - - // Store a reference to the element to call its parent methods - this._element = element || null + create: function () { this._timeSource = function () { return time.now() } @@ -54,12 +51,6 @@ SVG.Timeline = SVG.invent({ return this._dispatcher }, - // FIXME: there is no need anymore to save the element on the timeline - element (element) { - if(element == null) return this._element - this._element = element - }, - /** * */ @@ -73,6 +64,13 @@ SVG.Timeline = SVG.invent({ }) } + if (!this.active()) { + this._step() + if (when == null) { + when = 'now' + } + } + // The start time for the next animation can either be given explicitly, // derived from the current timeline time or it can be relative to the // last start time to chain animations direclty @@ -277,6 +275,10 @@ SVG.Timeline = SVG.invent({ if (!this._nextFrame) this._nextFrame = SVG.Animator.frame(this._step.bind(this)) return this + }, + + active () { + return !!this._nextFrame } }, @@ -284,7 +286,7 @@ SVG.Timeline = SVG.invent({ parent: SVG.Element, construct: { timeline: function () { - this._timeline = (this._timeline || new SVG.Timeline(this)) + this._timeline = (this._timeline || new SVG.Timeline()) return this._timeline }, } -- 2.39.5