aboutsummaryrefslogtreecommitdiffstats
path: root/src/fx.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-30 22:29:10 +0200
committerGitHub <noreply@github.com>2017-04-30 22:29:10 +0200
commitbd04216e0b13114e985ad144d5ca006c5a6a0087 (patch)
tree93fdcad68b1bf662c95d520a642cb66ad4f5f53c /src/fx.js
parent0ba5e1f394911c66441ea770e09338e82fb6ef49 (diff)
downloadsvg.js-bd04216e0b13114e985ad144d5ca006c5a6a0087.tar.gz
svg.js-bd04216e0b13114e985ad144d5ca006c5a6a0087.zip
Adds the intended functionality to call animate functions with multiple parameter (#671)
e.g. `el.animate().zoom(level, point)`
Diffstat (limited to 'src/fx.js')
-rw-r--r--src/fx.js36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/fx.js b/src/fx.js
index a4d0ecd..365273e 100644
--- a/src/fx.js
+++ b/src/fx.js
@@ -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){
@@ -845,9 +859,13 @@ SVG.extend(SVG.FX, {
return this
}
// 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) {