summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-09-20 14:14:40 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-09-20 14:14:40 +0200
commit136ac74503425027ec19365041b279f3a7036959 (patch)
tree0d55fb8cf45046e8ab5359371de2520b735ddfbe /src
parent6270500e28c419bf01626af72d8d65a8eab9fe1b (diff)
downloadsvg.js-136ac74503425027ec19365041b279f3a7036959.tar.gz
svg.js-136ac74503425027ec19365041b279f3a7036959.zip
get rid of that unnecessary bbox call on every frame
Diffstat (limited to 'src')
-rw-r--r--src/helpers.js11
-rw-r--r--src/matrix.js5
-rw-r--r--src/transform.js6
3 files changed, 16 insertions, 6 deletions
diff --git a/src/helpers.js b/src/helpers.js
index 9982b36..4b55897 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -204,6 +204,17 @@ function closeEnough (a, b, threshold) {
return Math.abs(b - a) < (threshold || 1e-6)
}
+function isMatrixLike (o) {
+ return (
+ o.a != null ||
+ o.b != null ||
+ o.c != null ||
+ o.d != null ||
+ o.e != null ||
+ o.f != null
+ )
+}
+
// TODO: Refactor this to a static function of matrix.js
function formatTransforms (o) {
// Get all of the parameters required to form the matrix
diff --git a/src/matrix.js b/src/matrix.js
index 2a9f2a9..e0bc08a 100644
--- a/src/matrix.js
+++ b/src/matrix.js
@@ -9,10 +9,7 @@ SVG.Matrix = SVG.invent({
source = source instanceof SVG.Element ? source.matrixify()
: typeof source === 'string' ? arrayToMatrix(source.split(SVG.regex.delimiter).map(parseFloat))
: Array.isArray(source) ? arrayToMatrix(source)
- : (typeof source === 'object' && (
- source.a != null || source.b != null || source.c != null ||
- source.d != null || source.e != null || source.f != null
- )) ? source
+ : (typeof source === 'object' && isMatrixLike(source)) ? source
: (typeof source === 'object') ? new SVG.Matrix().transform(source)
: arguments.length === 6 ? arrayToMatrix([].slice.call(arguments))
: base
diff --git a/src/transform.js b/src/transform.js
index 35eb53e..6ea5269 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -57,8 +57,10 @@ SVG.extend(SVG.Element, {
return decomposed[o] || decomposed
}
- // Set the origin according to the defined transform
- o = {...o, origin: getOrigin(o, this)}
+ if (!isMatrixLike(o)) {
+ // Set the origin according to the defined transform
+ o = {...o, origin: getOrigin(o, this)}
+ }
// The user can pass a boolean, an SVG.Element or an SVG.Matrix or nothing
var cleanRelative = relative === true ? this : (relative || false)