diff --git a/packages/cax-svg-omip/src/components/cax-element/render/display/display-object.js b/packages/cax-svg-omip/src/components/cax-element/render/display/display-object.js index 8a5d60620..b7ffecf6b 100755 --- a/packages/cax-svg-omip/src/components/cax-element/render/display/display-object.js +++ b/packages/cax-svg-omip/src/components/cax-element/render/display/display-object.js @@ -21,6 +21,9 @@ class DisplayObject extends EventDispatcher { this.absClipRuleNonzero = true this.cacheUpdating = false + this.boundsX = 0 + this.boundsY = 0 + try { Object.defineProperties(this, { stage: { get: this._getStage }, @@ -35,6 +38,7 @@ class DisplayObject extends EventDispatcher { }) } catch (e) {} + //不推荐,使用 boundsX、boundsX、width、height代替 this.hitBox = null } @@ -67,6 +71,11 @@ class DisplayObject extends EventDispatcher { ty = this.hitBox[0] * mtx.b + this.hitBox[1] * mtx.d + ty } + if (this.boundsX || this.boundsY) { + tx = this.boundsX * mtx.a + this.boundsY * mtx.c + tx + ty = this.boundsX * mtx.b + this.boundsY * mtx.d + ty + } + let xA = width * mtx.a, xB = width * mtx.b, yC = height * mtx.c, diff --git a/packages/cax-svg-omip/src/components/cax-element/svg/parse-transform.js b/packages/cax-svg-omip/src/components/cax-element/svg/parse-transform.js index e109b88f1..4c73d8265 100644 --- a/packages/cax-svg-omip/src/components/cax-element/svg/parse-transform.js +++ b/packages/cax-svg-omip/src/components/cax-element/svg/parse-transform.js @@ -54,4 +54,11 @@ export function transform(props, target) { target.width = parseFloat(props.width) target.height = parseFloat(props.height) } + + if (props['bounds-x']) { + target.boundsX = parseFloat(props['bounds-x']) + } + if (props['bounds-y']) { + target.boundsY = parseFloat(props['bounds-y']) + } } diff --git a/packages/cax-svg/cax/render/display/display-object.js b/packages/cax-svg/cax/render/display/display-object.js index 8a5d60620..b7ffecf6b 100755 --- a/packages/cax-svg/cax/render/display/display-object.js +++ b/packages/cax-svg/cax/render/display/display-object.js @@ -21,6 +21,9 @@ class DisplayObject extends EventDispatcher { this.absClipRuleNonzero = true this.cacheUpdating = false + this.boundsX = 0 + this.boundsY = 0 + try { Object.defineProperties(this, { stage: { get: this._getStage }, @@ -35,6 +38,7 @@ class DisplayObject extends EventDispatcher { }) } catch (e) {} + //不推荐,使用 boundsX、boundsX、width、height代替 this.hitBox = null } @@ -67,6 +71,11 @@ class DisplayObject extends EventDispatcher { ty = this.hitBox[0] * mtx.b + this.hitBox[1] * mtx.d + ty } + if (this.boundsX || this.boundsY) { + tx = this.boundsX * mtx.a + this.boundsY * mtx.c + tx + ty = this.boundsX * mtx.b + this.boundsY * mtx.d + ty + } + let xA = width * mtx.a, xB = width * mtx.b, yC = height * mtx.c, diff --git a/packages/cax-svg/cax/svg/parse-transform.js b/packages/cax-svg/cax/svg/parse-transform.js index e109b88f1..4c73d8265 100644 --- a/packages/cax-svg/cax/svg/parse-transform.js +++ b/packages/cax-svg/cax/svg/parse-transform.js @@ -54,4 +54,11 @@ export function transform(props, target) { target.width = parseFloat(props.width) target.height = parseFloat(props.height) } + + if (props['bounds-x']) { + target.boundsX = parseFloat(props['bounds-x']) + } + if (props['bounds-y']) { + target.boundsY = parseFloat(props['bounds-y']) + } } diff --git a/packages/cax-svg/pages/batman/index.js b/packages/cax-svg/pages/batman/index.js index 8dc744272..b4e85f745 100644 --- a/packages/cax-svg/pages/batman/index.js +++ b/packages/cax-svg/pages/batman/index.js @@ -7,7 +7,7 @@ Page({ const svg = renderSVG(html` -