@leafer/helper 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/LeafHelper.ts +15 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/helper",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "@leafer/helper",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.2.0"
25
+ "@leafer/math": "1.2.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.2.0"
28
+ "@leafer/interface": "1.2.2"
29
29
  }
30
30
  }
package/src/LeafHelper.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IAlign, ILeaf, IMatrixData, IPointData, IAxis } from '@leafer/interface'
2
- import { MathHelper, MatrixHelper, PointHelper, AroundHelper, getMatrixData } from '@leafer/math'
2
+ import { MathHelper, MatrixHelper, PointHelper, AroundHelper, getMatrixData, BoundsHelper } from '@leafer/math'
3
3
 
4
4
 
5
5
  const { copy, toInnerPoint, toOuterPoint, scaleOfOuter, rotateOfOuter, skewOfOuter, multiplyParent, divideParent, getLayout } = MatrixHelper
@@ -143,17 +143,22 @@ export const LeafHelper = {
143
143
  },
144
144
 
145
145
  setTransform(t: ILeaf, transform: IMatrixData, resize?: boolean): void {
146
- const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around))
146
+ const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin)
147
+ const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around))
147
148
  if (resize) {
148
- const scaleX = layout.scaleX / t.scaleX
149
- const scaleY = layout.scaleY / t.scaleY
150
- delete layout.scaleX
151
- delete layout.scaleY
152
- t.set(layout)
153
- t.scaleResize(scaleX, scaleY, resize !== true)
154
- } else {
149
+ const scaleX = layout.scaleX / t.scaleX, scaleY = layout.scaleY / t.scaleY
150
+ delete layout.scaleX, delete layout.scaleY
151
+
152
+ if (originPoint) { // fix origin: resize 方式下 boxBounds 会变化,导致 originPoint 不准确,需偏移至正确的位置
153
+ BoundsHelper.scale(t.boxBounds, Math.abs(scaleX), Math.abs(scaleY))
154
+ const changedPoint = L.getInnerOrigin(t, data.origin)
155
+ PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y)
156
+ }
157
+
155
158
  t.set(layout)
156
- }
159
+ t.scaleResize(scaleX, scaleY, false)
160
+
161
+ } else t.set(layout)
157
162
  },
158
163
 
159
164
  getFlipTransform(t: ILeaf, axis: IAxis): IMatrixData {