aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md9
-rw-r--r--package.json2
-rw-r--r--src/animation/Animator.js8
-rw-r--r--src/animation/Runner.js34
-rw-r--r--src/animation/Timeline.js17
-rw-r--r--src/elements/G.js8
6 files changed, 53 insertions, 25 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fbf9aad..3611fb8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,14 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http:
====
+## [3.0.3] - 2018-12-05
+
+### Fixed
+- fixed `Runner` which correctly retains transformations when it is still on a timeline
+- fixed `plot()` method of Runner
+- fixed `timeline()` so that one can set the timeline of an element now
+- fixed `G` and added missing `width/height`
+
## [3.0.2] - 2018-12-03
### Fixed
@@ -737,6 +745,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http:
<!-- Headings above link to the releases listed here -->
+[3.0.3]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.3
[3.0.2]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.2
[3.0.1]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.1
[3.0.0]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.0
diff --git a/package.json b/package.json
index b054d5e..9e11632 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@svgdotjs/svg.js",
- "version": "3.0.2",
+ "version": "3.0.3",
"description": "A lightweight library for manipulating and animating SVG.",
"url": "https://svgdotjs.github.io/",
"homepage": "https://svgdotjs.github.io/",
diff --git a/src/animation/Animator.js b/src/animation/Animator.js
index 2786602..64570eb 100644
--- a/src/animation/Animator.js
+++ b/src/animation/Animator.js
@@ -21,10 +21,6 @@ const Animator = {
return node
},
- transform_frame (fn, id) {
- Animator.transforms[id] = fn
- },
-
timeout (fn, delay) {
delay = delay || 0
@@ -74,10 +70,6 @@ const Animator = {
nextFrame.run()
}
- Animator.transforms.forEach(function (el) {
- el()
- })
-
// If we have remaining timeouts or frames, draw until we don't anymore
Animator.nextDraw = Animator.timeouts.first() || Animator.frames.first()
? globals.window.requestAnimationFrame(Animator._draw)
diff --git a/src/animation/Runner.js b/src/animation/Runner.js
index d211876..6a085b6 100644
--- a/src/animation/Runner.js
+++ b/src/animation/Runner.js
@@ -65,6 +65,8 @@ export default class Runner extends EventTarget {
this._wait = 0
this._times = 1
+ this._frameId = null
+
// Stores how long a runner is stored after beeing done
this._persist = this._isDeclarative ? true : null
}
@@ -441,7 +443,7 @@ export default class Runner extends EventTarget {
// TODO: Keep track of all transformations so that deletion is faster
clearTransformsFromQueue () {
- if (!this.done) {
+ if (!this.done || !this._timeline || !this._timeline._order.includes(this)) {
this._queue = this._queue.filter((item) => {
return !item.isTransform
})
@@ -558,7 +560,14 @@ class RunnerArray {
merge () {
let lastRunner = null
this.runners.forEach((runner, i) => {
- if (lastRunner && runner.done && lastRunner.done) {
+
+ const condition = lastRunner
+ && runner.done && lastRunner.done
+ // don't merge runner when persisted on timeline
+ && (!runner._timeline || !runner._timeline._order.includes(runner.id))
+ && (!lastRunner._timeline || !lastRunner._timeline._order.includes(lastRunner.id))
+
+ if (condition) {
this.remove(runner.id)
this.edit(lastRunner.id, runner.mergeWith(lastRunner))
}
@@ -589,7 +598,6 @@ class RunnerArray {
}
}
-let frameId = 0
registerMethods({
Element: {
animate (duration, delay, when) {
@@ -627,17 +635,18 @@ registerMethods({
_addRunner (runner) {
this._transformationRunners.add(runner)
- Animator.transform_frame(
- mergeTransforms.bind(this), this._frameId
- )
+ // Make sure that the runner merge is executed at the very end of
+ // all Animator functions. Thats why we use setTimeout here
+ setTimeout(() => {
+ Animator.cancelFrame(this._frameId)
+ this._frameId = Animator.frame(mergeTransforms.bind(this))
+ }, 0)
},
_prepareRunner () {
if (this._frameId == null) {
this._transformationRunners = new RunnerArray()
.add(new FakeRunner(new Matrix(this)))
-
- this._frameId = frameId++
}
}
}
@@ -689,6 +698,7 @@ extend(Runner, {
morpher.to(newLevel)
})
+ this._rememberMorpher('zoom', morpher)
return this
},
@@ -794,6 +804,7 @@ extend(Runner, {
currentAngle = affineParameters.rotate
current = new Matrix(affineParameters)
+ element._addRunner(this)
this.addTransform(current)
return morpher.done()
}
@@ -940,14 +951,19 @@ extend(Runner, {
return this.plot([ a, b, c, d ])
}
- var morpher = this._element.MorphArray().to(a)
+ if (this._tryRetarget('plot', a)) return this
+
+ var morpher = new Morphable(this._stepper)
+ .type(this._element.MorphArray).to(a)
this.queue(function () {
morpher.from(this._element.array())
}, function (pos) {
this._element.plot(morpher.at(pos))
+ return morpher.done()
})
+ this._rememberMorpher('plot', morpher)
return this
},
diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js
index 44b5261..56198e0 100644
--- a/src/animation/Timeline.js
+++ b/src/animation/Timeline.js
@@ -45,9 +45,7 @@ export default class Timeline extends EventTarget {
// schedules a runner on the timeline
schedule (runner, delay, when) {
if (runner == null) {
- return this._runners.map(makeSchedule).sort(function (a, b) {
- return a.runner.id - b.runner.id
- })
+ return this._order.map((id) => makeSchedule(this._runners[id]))
}
// The start time for the next animation can either be given explicitly,
@@ -218,7 +216,7 @@ export default class Timeline extends EventTarget {
if (dtToStart <= 0) {
runnersLeft = true
- // This is for the case that teh timeline was seeked so that the time
+ // This is for the case that the timeline was seeked so that the time
// is now before the startTime of the runner. Thats why we need to set
// the runner to position 0
runner.reset()
@@ -281,9 +279,14 @@ export default class Timeline extends EventTarget {
registerMethods({
Element: {
- timeline: function () {
- this._timeline = (this._timeline || new Timeline())
- return this._timeline
+ timeline: function (timeline) {
+ if (timeline == null) {
+ this._timeline = (this._timeline || new Timeline())
+ return this._timeline
+ } else {
+ this._timeline = timeline
+ return this
+ }
}
}
})
diff --git a/src/elements/G.js b/src/elements/G.js
index 398554a..0a11c1e 100644
--- a/src/elements/G.js
+++ b/src/elements/G.js
@@ -32,6 +32,14 @@ export default class G extends Container {
dmove (dx, dy) {
return this.transform({ dx, dy }, true)
}
+
+ width () {
+ return this.bbox().width
+ }
+
+ height () {
+ return this.bbox().height
+ }
}
registerMethods({