summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Tétreault <tetreault.remi@gmail.com>2017-05-26 18:51:36 -0400
committerGitHub <noreply@github.com>2017-05-26 18:51:36 -0400
commitdbbcc1669883f284125b4a1facf3120fa534ba8e (patch)
tree733772832a6d7534835d62909401d418775dab00
parentd80d692271345f73c45be0b67d44e3e3c1ecf35c (diff)
parent830e4c70b161fce24524455ef0bbd46a53b04fc8 (diff)
downloadsvg.js-dbbcc1669883f284125b4a1facf3120fa534ba8e.tar.gz
svg.js-dbbcc1669883f284125b4a1facf3120fa534ba8e.zip
Merge pull request #676 from jcorentin/fix-height-width-animation
Make width() and height() setters animatable
-rw-r--r--spec/spec/fx.js16
-rw-r--r--src/fx.js8
2 files changed, 24 insertions, 0 deletions
diff --git a/spec/spec/fx.js b/spec/spec/fx.js
index edf2081..17fbcc8 100644
--- a/spec/spec/fx.js
+++ b/spec/spec/fx.js
@@ -2556,6 +2556,22 @@ describe('FX', function() {
expect(fx.add).toHaveBeenCalledWith('height', jasmine.objectContaining({value:60}))
})
})
+
+ describe('width()', function() {
+ it('should set width with add()', function() {
+ spyOn(fx, 'add').and.callThrough()
+ fx.width(20)
+ expect(fx.add).toHaveBeenCalledWith('width', jasmine.objectContaining({value:20}))
+ })
+ })
+
+ describe('height()', function() {
+ it('should set height with add()', function() {
+ spyOn(fx, 'add').and.callThrough()
+ fx.height(20)
+ expect(fx.add).toHaveBeenCalledWith('height', jasmine.objectContaining({value:20}))
+ })
+ })
describe('plot()', function() {
it('should call add with plot as method', function() {
diff --git a/src/fx.js b/src/fx.js
index 3d8d6fe..36535b1 100644
--- a/src/fx.js
+++ b/src/fx.js
@@ -862,6 +862,14 @@ 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(a, b, c, d) {
// Lines can be plotted with 4 arguments