From 41b55427a71f85e444a8729a552b4db5aa9ac772 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Mon, 6 Mar 2017 18:52:28 +0100 Subject: make flip working with both axis when no parameter / only offset is passed --- src/matrix.js | 7 ++++++- src/sugar.js | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/matrix.js b/src/matrix.js index 356b790..c040b7a 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -115,7 +115,12 @@ SVG.Matrix = SVG.invent({ } // Flip matrix on x or y, at a given offset , flip: function(a, o) { - return a == 'x' ? this.scale(-1, 1, o, 0) : this.scale(1, -1, 0, o) + o = typeof a == 'number' ? a : o + return a == 'x' ? + this.scale(-1, 1, o, 0) : + a == 'y' ? + this.scale(1, -1, 0, o) : + this.scale(-1, -1, o, o) } // Skew , skew: function(x, y, cx, cy) { diff --git a/src/sugar.js b/src/sugar.js index e5bea4e..098c892 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -53,7 +53,8 @@ SVG.extend(SVG.Element, SVG.FX, { } // Map flip to transform , flip: function(a, o) { - return this.transform({ flip: a, offset: o }) + o = typeof a == 'number' ? a : o + return this.transform({ flip: a || 'both', offset: o }) } // Map matrix to transform , matrix: function(m) { -- cgit v1.2.3