diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-12-03 22:59:58 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-12-03 22:59:58 +0100 |
commit | f089db0c1990d75bbd34713f97f547045ae92fca (patch) | |
tree | a0aa8346394aae92fff16ff4f1f452b30909cb5a | |
parent | c336bd4a1c8e129efffed63424b724a148f053b3 (diff) | |
download | svg.js-f089db0c1990d75bbd34713f97f547045ae92fca.tar.gz svg.js-f089db0c1990d75bbd34713f97f547045ae92fca.zip |
Release 3.0.23.0.2
-rw-r--r-- | CHANGELOG.md | 13 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | src/animation/Morphable.js | 7 | ||||
-rw-r--r-- | src/animation/Runner.js | 43 | ||||
-rw-r--r-- | src/animation/Timeline.js | 5 | ||||
-rw-r--r-- | src/modules/core/attr.js | 2 | ||||
-rw-r--r-- | src/types/Box.js | 5 | ||||
-rw-r--r-- | src/types/Color.js | 3 | ||||
-rw-r--r-- | src/types/EventTarget.js | 3 | ||||
-rw-r--r-- | src/types/List.js | 6 | ||||
-rw-r--r-- | src/types/Matrix.js | 3 |
11 files changed, 74 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ae1e713..fbf9aad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,21 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http: ==== +## [3.0.2] - 2018-12-03 + +### Fixed +- fixed `List` which still didn't have all method names it should have +- fixed `Runner` which correctly handle retargeted controlled animations now +- fixed `Runner` so that it is able to be persisted correctly +- fixed `Color` which correctly handles empty strings now +- fixed `attr` which correctly handles Objects of other kind now +- fixed `Morphable` which correctly calculates the done flag now + ## [3.0.1] - 2018-12-03 ### Fixed - fixed `insertBefore`, `insertAfter` and `flip` correctly returning `this` -- fixed `List` which didnt have all method names it should have +- fixed `List` which didn't have all method names it should have ## [3.0.0] - 2018-12-01 @@ -727,6 +737,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http: <!-- Headings above link to the releases listed here --> +[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 aec21e3..b054d5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@svgdotjs/svg.js", - "version": "3.0.1", + "version": "3.0.2", "description": "A lightweight library for manipulating and animating SVG.", "url": "https://svgdotjs.github.io/", "homepage": "https://svgdotjs.github.io/", @@ -64,7 +64,7 @@ "test:svgdom": "node -r esm ./spec/runSVGDomTest.js || true", "test:es6": "npx karma start .config/karma.es6.js --single-run", "zip": "zip -j dist/svg.js.zip -- LICENSE.txt README.md CHANGELOG.md dist/svg.js dist/svg.js.map dist/svg.min.js dist/svg.min.js.map dist/polyfills.js dist/polyfillsIE.js", - "prepublishOnly": "npm run build && npm run build:polyfills && npm test", + "prepublishOnly": "rm -r ./dist && npm run build && npm run build:polyfills && npm test", "postpublish": "npm run zip" }, "devDependencies": { diff --git a/src/animation/Morphable.js b/src/animation/Morphable.js index 56ffe95..0f191c9 100644 --- a/src/animation/Morphable.js +++ b/src/animation/Morphable.js @@ -90,7 +90,12 @@ export default class Morphable { this._morphObj = this._morphObj || new this._type() this._context = this._context - || Array.apply(null, Array(result.length)).map(Object) + || Array.apply(null, Array(result.length)) + .map(Object) + .map(function (o) { + o.done = true + return o + }) return result } diff --git a/src/animation/Runner.js b/src/animation/Runner.js index 3af5823..d211876 100644 --- a/src/animation/Runner.js +++ b/src/animation/Runner.js @@ -1,5 +1,5 @@ import { Controller, Ease, Stepper } from './Controller.js' -import { extend } from '../utils/adopter.js' +import { extend, register } from '../utils/adopter.js' import { from, to } from '../modules/core/gradiented.js' import { getOrigin } from '../utils/utils.js' import { noop, timeline } from '../modules/core/defaults.js' @@ -64,6 +64,9 @@ export default class Runner extends EventTarget { this._swing = false this._wait = 0 this._times = 1 + + // Stores how long a runner is stored after beeing done + this._persist = this._isDeclarative ? true : null } /* @@ -199,6 +202,12 @@ export default class Runner extends EventTarget { return this.time(time) } + persist (dtOrForever) { + if (dtOrForever == null) return this._persist + this._persist = dtOrForever + return this + } + position (p) { // Get all of the variables we need var x = this._time @@ -338,11 +347,22 @@ export default class Runner extends EventTarget { morpher: morpher, caller: this._queue[this._queue.length - 1] } + + // We have to resume the timeline in case a controller + // is already done without beeing ever run + // This can happen when e.g. this is done: + // anim = el.animate(new SVG.Spring) + // and later + // anim.move(...) + if (this._isDeclarative) { + var timeline = this.timeline() + timeline && timeline.play() + } } // Try to set the target for a morpher if the morpher exists, otherwise // do nothing and return false - _tryRetarget (method, target) { + _tryRetarget (method, target, extra) { if (this._history[method]) { // if the last method wasnt even initialised, throw it away if (!this._history[method].caller.initialised) { @@ -354,7 +374,7 @@ export default class Runner extends EventTarget { // for the case of transformations, we use the special retarget function // which has access to the outer scope if (this._history[method].caller.retarget) { - this._history[method].caller.retarget(target) + this._history[method].caller.retarget(target, extra) // for everything else a simple morpher change is sufficient } else { this._history[method].morpher.to(target) @@ -362,7 +382,7 @@ export default class Runner extends EventTarget { this._history[method].caller.finished = false var timeline = this.timeline() - timeline && timeline._continue() + timeline && timeline.play() return true } return false @@ -604,7 +624,7 @@ registerMethods({ .reduce(lmultiply, new Matrix()) }, - addRunner (runner) { + _addRunner (runner) { this._transformationRunners.add(runner) Animator.transform_frame( @@ -636,9 +656,10 @@ extend(Runner, { styleAttr (type, name, val) { // apply attributes individually if (typeof name === 'object') { - for (var key in val) { - this.styleAttr(type, key, val[key]) + for (var key in name) { + this.styleAttr(type, key, name[key]) } + return this } var morpher = new Morphable(this._stepper).to(val) @@ -654,6 +675,8 @@ extend(Runner, { }, zoom (level, point) { + if (this._tryRetarget('zoom', to, point)) return this + var morpher = new Morphable(this._stepper).to(new SVGNumber(level)) this.queue(function () { @@ -661,6 +684,9 @@ extend(Runner, { }, function (pos) { this.element().zoom(morpher.at(pos), point) return morpher.done() + }, function (newLevel, newPoint) { + point = newPoint + morpher.to(newLevel) }) return this @@ -714,7 +740,7 @@ extend(Runner, { startTransform = new Matrix(relative ? undefined : element) // add the runner to the element so it can merge transformations - element.addRunner(this) + element._addRunner(this) // Deactivate all transforms that have run so far if we are absolute if (!relative) { @@ -953,3 +979,4 @@ extend(Runner, { }) extend(Runner, { rx, ry, from, to }) +register(Runner) diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js index c3ad07c..44b5261 100644 --- a/src/animation/Timeline.js +++ b/src/animation/Timeline.js @@ -80,11 +80,12 @@ export default class Timeline extends EventTarget { // Manage runner runner.unschedule() runner.timeline(this) - // runner.time(-delay) + + const persist = runner.persist() // Save runnerInfo this._runners[runner.id] = { - persist: this.persist(), + persist: persist === null ? this._persist : persist, runner: runner, start: absoluteStartTime + delay } diff --git a/src/modules/core/attr.js b/src/modules/core/attr.js index 79dd0d7..548a6fb 100644 --- a/src/modules/core/attr.js +++ b/src/modules/core/attr.js @@ -30,7 +30,7 @@ export default function attr (attr, val, ns) { last[curr] = this.attr(curr) return last }, {}) - } else if (typeof attr === 'object') { + } else if (typeof attr === 'object' && attr.constructor === Object) { // apply every attribute individually if an object is passed for (val in attr) this.attr(val, attr[val]) } else if (val === null) { diff --git a/src/types/Box.js b/src/types/Box.js index d2ddcdd..3df1367 100644 --- a/src/types/Box.js +++ b/src/types/Box.js @@ -1,6 +1,7 @@ import { delimiter } from '../modules/core/regex.js' -import { registerMethods } from '../utils/methods.js' import { globals } from '../utils/window.js' +import { register } from '../utils/adopter.js' +import { registerMethods } from '../utils/methods.js' import Point from './Point.js' import parser from '../modules/core/parser.js' @@ -152,3 +153,5 @@ registerMethods({ } } }) + +register(Box) diff --git a/src/types/Color.js b/src/types/Color.js index a1329aa..93ca570 100644 --- a/src/types/Color.js +++ b/src/types/Color.js @@ -63,6 +63,9 @@ export default class Color { } init (a = 0, b = 0, c = 0, d = 0, space = 'rgb') { + // This catches the case when a falsy value is passed like '' + a = !a ? 0 : a + // Reset all values in case the init function is rerun with new color space if (this.space) { for (let component in this.space) { diff --git a/src/types/EventTarget.js b/src/types/EventTarget.js index 5a005fd..d414dd8 100644 --- a/src/types/EventTarget.js +++ b/src/types/EventTarget.js @@ -1,4 +1,5 @@ import { dispatch, off, on } from '../modules/core/event.js' +import { register } from '../utils/adopter.js' import Base from './Base.js' export default class EventTarget extends Base { @@ -56,3 +57,5 @@ export default class EventTarget extends Base { removeEventListener () {} } + +register(EventTarget) diff --git a/src/types/List.js b/src/types/List.js index 44f0fed..f66e3cd 100644 --- a/src/types/List.js +++ b/src/types/List.js @@ -13,16 +13,14 @@ export default List extend(List, { each (fnOrMethodName, ...args) { if (typeof fnOrMethodName === 'function') { - this.forEach((el) => { - fnOrMethodName.call(el, el) + return this.map((el) => { + return fnOrMethodName.call(el, el) }) } else { return this.map(el => { return el[fnOrMethodName](...args) }) } - - return this }, toArray () { diff --git a/src/types/Matrix.js b/src/types/Matrix.js index 102192b..ef90ca3 100644 --- a/src/types/Matrix.js +++ b/src/types/Matrix.js @@ -1,5 +1,6 @@ import { delimiter } from '../modules/core/regex.js' import { radians } from '../utils/utils.js' +import { register } from '../utils/adopter.js' import Element from '../elements/Element.js' import Point from './Point.js' @@ -498,3 +499,5 @@ export function screenCTM () { } return new Matrix(this.node.getScreenCTM()) } + +register(Matrix) |