diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-02-25 15:05:59 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-02-25 15:05:59 +0100 |
commit | dd0f06f9a15e991021c1e8cbd007e3b8b67ddcde (patch) | |
tree | 63ea4e4fca4087c46e3eaf0cc9647f781e4f0bcd /src | |
parent | e7c025d2a4f8f536432870ebac903e24392896f0 (diff) | |
download | svg.js-dd0f06f9a15e991021c1e8cbd007e3b8b67ddcde.tar.gz svg.js-dd0f06f9a15e991021c1e8cbd007e3b8b67ddcde.zip |
viewbox now also accepts arrays and strings
Diffstat (limited to 'src')
-rw-r--r-- | src/viewbox.js | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/viewbox.js b/src/viewbox.js index 7bf307d..8ce7e04 100644 --- a/src/viewbox.js +++ b/src/viewbox.js @@ -86,28 +86,21 @@ SVG.ViewBox = SVG.invent({ toString: function() { return this.x + ' ' + this.y + ' ' + this.width + ' ' + this.height } - , morph: function(v){ - - var v = arguments.length == 1 ? - [v.x, v.y, v.width, v.height] : - [].slice.call(arguments) - - this.destination = new SVG.ViewBox(v) - + , morph: function(x, y, width, height){ + this.destination = new SVG.ViewBox(x, y, width, height) return this - } , at: function(pos) { - if(!this.destination) return this + if(!this.destination) return this - return new SVG.ViewBox([ - this.x + (this.destination.x - this.x) * pos - , this.y + (this.destination.y - this.y) * pos - , this.width + (this.destination.width - this.width) * pos - , this.height + (this.destination.height - this.height) * pos - ]) + return new SVG.ViewBox([ + this.x + (this.destination.x - this.x) * pos + , this.y + (this.destination.y - this.y) * pos + , this.width + (this.destination.width - this.width) * pos + , this.height + (this.destination.height - this.height) * pos + ]) } @@ -120,17 +113,13 @@ SVG.ViewBox = SVG.invent({ , construct: { // get/set viewbox - viewbox: function(v) { + viewbox: function(x, y, width, height) { if (arguments.length == 0) // act as a getter if there are no arguments return new SVG.ViewBox(this) // otherwise act as a setter - v = arguments.length == 1 ? - [v.x, v.y, v.width, v.height] : - [].slice.call(arguments) - - return this.attr('viewBox', v) + return this.attr('viewBox', new SVG.ViewBox(x, y, width, height)) } } |