@leafer/helper 1.9.0 → 1.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/helper",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "@leafer/helper",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/data": "1.9.0",
26
- "@leafer/math": "1.9.0",
27
- "@leafer/platform": "1.9.0"
25
+ "@leafer/data": "1.9.2",
26
+ "@leafer/math": "1.9.2",
27
+ "@leafer/platform": "1.9.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.9.0"
30
+ "@leafer/interface": "1.9.2"
31
31
  }
32
32
  }
package/src/LeafHelper.ts CHANGED
@@ -94,7 +94,7 @@ export const LeafHelper = {
94
94
 
95
95
  moveWorld(t: ILeaf, x: number | IPointData, y = 0, isInnerPoint?: boolean, transition?: ITransition): void {
96
96
  const local = isObject(x) ? { ...x } : { x, y }
97
- isInnerPoint ? toOuterPoint(t.localTransform, local, local, true) : (t.parent && toInnerPoint(t.parent.worldTransform, local, local, true))
97
+ isInnerPoint ? toOuterPoint(t.localTransform, local, local, true) : (t.parent && toInnerPoint(t.parent.scrollWorldTransform, local, local, true))
98
98
  L.moveLocal(t, local.x, local.y, transition)
99
99
  },
100
100
 
@@ -118,7 +118,7 @@ export const LeafHelper = {
118
118
  }
119
119
  copy(matrix, o)
120
120
  scaleOfOuter(matrix, origin, scaleX, scaleY)
121
- if (t.origin || t.around) {
121
+ if (L.hasHighPosition(t)) {
122
122
  L.setTransform(t, matrix, resize, transition)
123
123
  } else {
124
124
  const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f
@@ -135,7 +135,7 @@ export const LeafHelper = {
135
135
  const o = t.__localMatrix
136
136
  copy(matrix, o)
137
137
  rotateOfOuter(matrix, origin, angle)
138
- if (t.origin || t.around) L.setTransform(t, matrix, false, transition)
138
+ if (L.hasHighPosition(t)) L.setTransform(t, matrix, false, transition)
139
139
  else t.set({ x: t.x + matrix.e - o.e, y: t.y + matrix.f - o.f, rotation: MathHelper.formatRotation(t.rotation + angle) }, transition)
140
140
  },
141
141
 
@@ -152,7 +152,7 @@ export const LeafHelper = {
152
152
  transformWorld(t: ILeaf, transform: IMatrixData, resize?: boolean, transition?: ITransition): void {
153
153
  copy(matrix, t.worldTransform)
154
154
  multiplyParent(matrix, transform)
155
- if (t.parent) divideParent(matrix, t.parent.worldTransform)
155
+ if (t.parent) divideParent(matrix, t.parent.scrollWorldTransform)
156
156
  L.setTransform(t, matrix, resize, transition)
157
157
  },
158
158
 
@@ -165,6 +165,12 @@ export const LeafHelper = {
165
165
  setTransform(t: ILeaf, transform: IMatrixData, resize?: boolean, transition?: ITransition): void {
166
166
  const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin)
167
167
  const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around))
168
+
169
+ if (L.hasOffset(t)) {
170
+ layout.x -= data.offsetX
171
+ layout.y -= data.offsetY
172
+ }
173
+
168
174
  if (resize) {
169
175
  const scaleX = layout.scaleX / t.scaleX, scaleY = layout.scaleY / t.scaleY
170
176
  delete layout.scaleX, delete layout.scaleY
@@ -200,7 +206,7 @@ export const LeafHelper = {
200
206
 
201
207
  getRelativeWorld(t: ILeaf, relative: ILeaf, temp?: boolean): IMatrixData {
202
208
  copy(matrix, t.worldTransform)
203
- divideParent(matrix, relative.worldTransform)
209
+ divideParent(matrix, relative.scrollWorldTransform)
204
210
  return temp ? matrix : { ...matrix }
205
211
  },
206
212
 
@@ -209,6 +215,14 @@ export const LeafHelper = {
209
215
  parent.add(t, index)
210
216
  },
211
217
 
218
+ hasHighPosition(t: ILeaf): boolean {
219
+ return (t.origin || t.around || L.hasOffset(t)) as unknown as boolean
220
+ },
221
+
222
+ hasOffset(t: ILeaf): boolean {
223
+ return (t.offsetX || t.offsetY) as unknown as boolean
224
+ },
225
+
212
226
  hasParent(p: ILeaf, parent: ILeaf): boolean | void {
213
227
  if (!parent) return false
214
228
  while (p) {
@@ -237,6 +251,5 @@ const L = LeafHelper
237
251
  const { updateAllMatrix, updateMatrix, updateAllWorldOpacity, updateAllChange, updateChange } = L
238
252
 
239
253
  function getTempLocal(t: ILeaf, world: IPointData): IPointData {
240
- t.__layout.update()
241
- return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world
254
+ return t.parent ? PointHelper.tempToInnerOf(world, t.parent.scrollWorldTransform) : world
242
255
  }
package/types/index.d.ts CHANGED
@@ -26,6 +26,8 @@ declare const LeafHelper: {
26
26
  getInnerOrigin(t: ILeaf, origin: IPointData | IAlign): IPointData;
27
27
  getRelativeWorld(t: ILeaf, relative: ILeaf, temp?: boolean): IMatrixData;
28
28
  drop(t: ILeaf, parent: ILeaf, index?: number, resize?: boolean): void;
29
+ hasHighPosition(t: ILeaf): boolean;
30
+ hasOffset(t: ILeaf): boolean;
29
31
  hasParent(p: ILeaf, parent: ILeaf): boolean | void;
30
32
  animateMove(t: ILeaf, move: IPointData, speed?: number): void;
31
33
  };