@leafer/layout 1.0.0-rc.17 → 1.0.0-rc.18

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 +5 -4
  2. package/src/LeafLayout.ts +16 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/layout",
3
- "version": "1.0.0-rc.17",
3
+ "version": "1.0.0-rc.18",
4
4
  "description": "@leafer/layout",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/math": "1.0.0-rc.17",
26
- "@leafer/platform": "1.0.0-rc.17"
25
+ "@leafer/math": "1.0.0-rc.18",
26
+ "@leafer/helper": "1.0.0-rc.18",
27
+ "@leafer/platform": "1.0.0-rc.18"
27
28
  },
28
29
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.17"
30
+ "@leafer/interface": "1.0.0-rc.18"
30
31
  }
31
32
  }
package/src/LeafLayout.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { ILeaf, ILeafLayout, ILocationType, IBoundsType, IBoundsData, IMatrixData, ILayoutBoundsData, IPointData } from '@leafer/interface'
2
- import { Bounds, BoundsHelper, Matrix, MatrixHelper, PointHelper } from '@leafer/math'
2
+ import { Bounds, BoundsHelper, MatrixHelper, PointHelper } from '@leafer/math'
3
+ import { LeafHelper } from '@leafer/helper'
3
4
  import { Platform } from '@leafer/platform'
4
5
 
5
6
 
6
- const tempMatrix = new Matrix()
7
+ const { getRelativeWorld } = LeafHelper
7
8
  const { toOuterOf, getPoints, copy } = BoundsHelper
8
9
 
9
10
  export class LeafLayout implements ILeafLayout {
@@ -119,15 +120,18 @@ export class LeafLayout implements ILeafLayout {
119
120
 
120
121
  public getTransform(relative: ILocationType | ILeaf = 'world'): IMatrixData {
121
122
  this.update()
123
+ const { leaf } = this
122
124
  switch (relative) {
123
125
  case 'world':
124
- return this.leaf.__world
126
+ return leaf.__world
125
127
  case 'local':
126
- return this.leaf.__localMatrix
128
+ return leaf.__localMatrix
127
129
  case 'inner':
128
130
  return MatrixHelper.defaultMatrix
131
+ case 'page':
132
+ relative = leaf.zoomLayer
129
133
  default:
130
- return new Matrix(this.leaf.__world).divideParent(relative.__world)
134
+ return getRelativeWorld(leaf, relative)
131
135
  }
132
136
  }
133
137
 
@@ -140,6 +144,8 @@ export class LeafLayout implements ILeafLayout {
140
144
  return this.getLocalBounds(type)
141
145
  case 'inner':
142
146
  return this.getInnerBounds(type)
147
+ case 'page':
148
+ relative = this.leaf.zoomLayer
143
149
  default:
144
150
  return new Bounds(this.getInnerBounds(type)).toOuterOf(this.getTransform(relative))
145
151
  }
@@ -204,9 +210,11 @@ export class LeafLayout implements ILeafLayout {
204
210
  point = bounds
205
211
  matrix = MatrixHelper.defaultMatrix
206
212
  break
213
+ case 'page':
214
+ relative = leaf.zoomLayer
207
215
  default:
208
216
  point = leaf.getWorldPoint(bounds, relative)
209
- matrix = tempMatrix.set(leaf.__world).divideParent(relative.__world)
217
+ matrix = getRelativeWorld(leaf, relative, true)
210
218
  }
211
219
 
212
220
  const layoutBounds = MatrixHelper.getLayout(matrix) as ILayoutBoundsData
@@ -241,6 +249,8 @@ export class LeafLayout implements ILeafLayout {
241
249
  break
242
250
  case 'inner':
243
251
  break
252
+ case 'page':
253
+ relative = leaf.zoomLayer
244
254
  default:
245
255
  relativeLeaf = relative
246
256
  }