aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-06-27 11:17:18 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-06-27 11:17:18 +0200
commit5836ecaba4d02bd2ff5c1ab727df5086911eda12 (patch)
tree4ab5fdded202329b02da9a0c9edddf2daeba3087 /src
parent6353b3d2f43f5899ebecab13b82ecadacdbb69b3 (diff)
downloadsvg.js-5836ecaba4d02bd2ff5c1ab727df5086911eda12.tar.gz
svg.js-5836ecaba4d02bd2ff5c1ab727df5086911eda12.zip
fix origin for relative transformations
Diffstat (limited to 'src')
-rw-r--r--src/helpers.js4
-rw-r--r--src/runner.js16
2 files changed, 9 insertions, 11 deletions
diff --git a/src/helpers.js b/src/helpers.js
index 3981c94..9159b4f 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -260,7 +260,7 @@ function formatTransforms (o) {
}
}
-function getOrigin (transforms, element) {
+function getOrigin (o, element) {
// Allow origin or around as the names
origin = o.around == null ? o.origin : o.around
@@ -268,7 +268,7 @@ function getOrigin (transforms, element) {
if ( typeof origin === 'string' || origin == null ) {
// Get the bounding box of the element with no transformations applied
const string = (origin || 'center').toLowerCase().trim()
- const { height, width, x, y } = this.bbox()
+ const { height, width, x, y } = element.bbox()
// Set the bounds eg : "bottom-left", "Top right", "middle" etc...
const ox = o.ox || string.includes('left') ? x
diff --git a/src/runner.js b/src/runner.js
index b137dba..c4fb418 100644
--- a/src/runner.js
+++ b/src/runner.js
@@ -592,7 +592,7 @@ SVG.extend(SVG.Runner, {
// 4. Now you get the delta matrix as a result: D = F * inv(M)
transform: function (transforms, relative, affine) {
- if (this._tryRetarget('transform', transforms)) {
+ if (this._isDeclarative && this._tryRetarget('transform', transforms)) {
return this
}
@@ -640,14 +640,12 @@ SVG.extend(SVG.Runner, {
transforms.origin = origin
let sanitisedTransforms = formatTransforms(transforms)
- morpher.from({origin})
+ morpher.from(formatTransforms({origin}))
- var from = morpher.from()
- var indexOfOffset = from.indexOf('offset')
+ var to = morpher.to()
+ var indexOfOffset = to.indexOf('ox')
if(indexOfOffset > -1) {
- let to = morpher.to()
- to[indexOfOffset+1] = origin
- to[indexOfOffset] = 'origin'
+ to.splice(indexOfOffset, 4, 'ox', origin[0], 'oy', origin[1])
}
this.element().addRunner(this)
@@ -656,7 +654,7 @@ SVG.extend(SVG.Runner, {
return morpher.done()
}, true)
- this._rememberMorpher('transform', morpher)
+ this._isDeclarative && this._rememberMorpher('transform', morpher)
return this
}
@@ -702,7 +700,7 @@ SVG.extend(SVG.Runner, {
}, true)
- this._rememberMorpher('transform', morpher)
+ this._isDeclarative && this._rememberMorpher('transform', morpher)
return this
},