diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-07-06 11:07:29 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-07-06 11:07:29 +0200 |
commit | f1bd0b48ea9cc3a499c02c524924e81eb97e9a6e (patch) | |
tree | 3f3779d3afd5126ccb7d97fd82a9f672cd677458 /src | |
parent | 0e72ab27955ad7706157dd6fcc1ce1db091d65cf (diff) | |
parent | a19b4f1dfe06d70775a03ec5428b0423fbb46819 (diff) | |
download | svg.js-f1bd0b48ea9cc3a499c02c524924e81eb97e9a6e.tar.gz svg.js-f1bd0b48ea9cc3a499c02c524924e81eb97e9a6e.zip |
Merge branch 'master' into 3.0.0
Conflicts (All resolved):
dist/svg.js
dist/svg.min.js
package.json
src/doc.js
Diffstat (limited to 'src')
-rw-r--r-- | src/fx.js | 60 | ||||
-rw-r--r-- | src/matrix.js | 2 | ||||
-rw-r--r-- | src/textpath.js | 3 |
3 files changed, 49 insertions, 16 deletions
@@ -214,7 +214,7 @@ SVG.FX = SVG.invent({ // updates all animations to the current state of the element // this is important when one property could be changed from another property , initAnimations: function() { - var i, source + var i, j, source var s = this.situation if(s.init) return this @@ -222,12 +222,26 @@ SVG.FX = SVG.invent({ for(i in s.animations){ source = this.target()[i]() - // The condition is because some methods return a normal number instead - // of a SVG.Number - if(s.animations[i] instanceof SVG.Number) - source = new SVG.Number(source) + if(!Array.isArray(source)) { + source = [source] + } + + if(!Array.isArray(s.animations[i])) { + s.animations[i] = [s.animations[i]] + } + + //if(s.animations[i].length > source.length) { + // source.concat = source.concat(s.animations[i].slice(source.length, s.animations[i].length)) + //} - s.animations[i] = source.morph(s.animations[i]) + for(j = source.length; j--;) { + // The condition is because some methods return a normal number instead + // of a SVG.Number + if(s.animations[i][j] instanceof SVG.Number) + source[j] = new SVG.Number(source[j]) + + s.animations[i][j] = source[j].morph(s.animations[i][j]) + } } for(i in s.attrs){ @@ -563,8 +577,12 @@ SVG.FX = SVG.invent({ if(!this.situations.length){ this.target().fire('allfinished') - this.target().off('.fx') // there shouldnt be any binding left, but to make sure... - this.active = false + + // Recheck the length since the user may call animate in the afterAll callback + if(!this.situations.length){ + this.target().off('.fx') // there shouldnt be any binding left, but to make sure... + this.active = false + } } // start next animation @@ -660,10 +678,10 @@ SVG.FX = SVG.invent({ // adds an once-callback which is called at a specific position and never again , once: function(pos, fn, isEased){ + var c = this.last() + if(!isEased) pos = c.ease(pos) - if(!isEased)pos = this.situation.ease(pos) - - this.situation.once[pos] = fn + c.once[pos] = fn return this } @@ -732,6 +750,8 @@ SVG.MorphObj = SVG.invent({ create: function(from, to){ // prepare color for morphing if(SVG.Color.isColor(to)) return new SVG.Color(from).morph(to) + // prepare value list for morphing + if(SVG.regex.delimiter.test(from)) return new SVG.Array(from).morph(to) // prepare number for morphing if(SVG.regex.numberAndUnit.test(to)) return new SVG.Number(from).morph(to) @@ -844,10 +864,22 @@ SVG.extend(SVG.FX, { return this } + // Add animatable width +, width: function(width) { + return this.add('width', new SVG.Number(width)) + } + // Add animatable height +, height: function(height) { + return this.add('height', new SVG.Number(height)) + } // Add animatable plot -, plot: function() { - // We use arguments here since SVG.Line's plot method can be passed 4 parameters - return this.add('plot', arguments.length > 1 ? [].slice.call(arguments) : arguments[0]) +, plot: function(a, b, c, d) { + // Lines can be plotted with 4 arguments + if(arguments.length == 4) { + return this.plot([a, b, c, d]) + } + + return this.add('plot', new (this.target().morphArray)(a)) } // Add leading method , leading: function(value) { diff --git a/src/matrix.js b/src/matrix.js index 7b8ced9..449f8b6 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -17,7 +17,7 @@ SVG.Matrix = SVG.invent({ // merge source for (i = abcdef.length - 1; i >= 0; --i) - this[abcdef[i]] = source && typeof source[abcdef[i]] === 'number' ? + this[abcdef[i]] = source[abcdef[i]] != null ? source[abcdef[i]] : base[abcdef[i]] } diff --git a/src/textpath.js b/src/textpath.js index 4750310..18e2149 100644 --- a/src/textpath.js +++ b/src/textpath.js @@ -10,8 +10,9 @@ SVG.TextPath = SVG.invent({ // Add parent method , construct: { + morphArray: SVG.PathArray // Create path for text to run on - path: function(d) { + , path: function(d) { // create textPath element var path = new SVG.TextPath , track = this.doc().defs().path(d) |