@leafer/layouter 1.0.0-alpha.10 → 1.0.0-alpha.23

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/layouter",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.23",
4
4
  "description": "@leafer/canvas",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,14 +19,14 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/event": "1.0.0-alpha.10",
23
- "@leafer/math": "1.0.0-alpha.10",
24
- "@leafer/list": "1.0.0-alpha.10",
25
- "@leafer/data": "1.0.0-alpha.10",
26
- "@leafer/helper": "1.0.0-alpha.10",
27
- "@leafer/debug": "1.0.0-alpha.10"
22
+ "@leafer/event": "1.0.0-alpha.23",
23
+ "@leafer/math": "1.0.0-alpha.23",
24
+ "@leafer/list": "1.0.0-alpha.23",
25
+ "@leafer/data": "1.0.0-alpha.23",
26
+ "@leafer/helper": "1.0.0-alpha.23",
27
+ "@leafer/debug": "1.0.0-alpha.23"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.0.0-alpha.10"
30
+ "@leafer/interface": "1.0.0-alpha.23"
31
31
  }
32
32
  }
@@ -26,7 +26,7 @@ export class LayoutBlockData implements ILayoutBlockData {
26
26
 
27
27
  public setAfter(): void {
28
28
  setByListWithHandle(this.afterBounds, this.updatedList.list, worldBounds)
29
- this.__computeChange()
29
+ this.updatedBounds.setByList([this.beforeBounds, this.afterBounds])
30
30
  }
31
31
 
32
32
  public merge(data: ILayoutBlockData): void {
@@ -36,15 +36,6 @@ export class LayoutBlockData implements ILayoutBlockData {
36
36
  this.updatedBounds.add(data.updatedBounds)
37
37
  }
38
38
 
39
- protected __computeChange(): void {
40
- const { updatedBounds: changedBounds } = this
41
- changedBounds.setByList([this.beforeBounds, this.afterBounds])
42
- if (!changedBounds.isEmpty()) {
43
- changedBounds.spread(2)
44
- changedBounds.ceil()
45
- }
46
- }
47
-
48
39
  public destroy(): void {
49
40
  this.updatedList = null
50
41
  }
package/src/Layouter.ts CHANGED
@@ -54,13 +54,11 @@ export class Layouter implements ILayouter {
54
54
  public layout(): void {
55
55
  if (!this.running) return
56
56
  const { target } = this
57
- const { LAYOUT, END } = LayoutEvent
58
57
  this.times = 0
59
58
  this.changed = false
60
59
  target.emit(LayoutEvent.START)
61
60
  this.layoutOnce()
62
- target.emitEvent(new LayoutEvent(LAYOUT, this.layoutedBlocks))
63
- target.emitEvent(new LayoutEvent(END, this.layoutedBlocks))
61
+ target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks))
64
62
  this.layoutedBlocks = null
65
63
  }
66
64
 
@@ -82,20 +80,21 @@ export class Layouter implements ILayouter {
82
80
 
83
81
  const t = Run.start('PartLayout')
84
82
  const { target, __updateList: updateList } = this
85
- const { BEFORE_ONCE, ONCE, AFTER_ONCE } = LayoutEvent
83
+ const { BEFORE, LAYOUT, AFTER } = LayoutEvent
86
84
 
87
85
  const blocks = this.getBlocks(updateList)
88
86
  blocks.forEach(item => { item.setBefore() })
89
- target.emitEvent(new LayoutEvent(BEFORE_ONCE, blocks))
87
+ target.emitEvent(new LayoutEvent(BEFORE, blocks))
90
88
 
91
89
  updateList.sort()
92
90
  updateMatrix(updateList, this.__levelList)
93
91
  updateBounds(this.__levelList)
94
92
  updateChange(updateList)
95
93
 
96
- blocks.forEach(item => { item.setAfter() })
97
- target.emitEvent(new LayoutEvent(ONCE, blocks))
98
- target.emitEvent(new LayoutEvent(AFTER_ONCE, blocks))
94
+ blocks.forEach(item => item.setAfter())
95
+
96
+ target.emitEvent(new LayoutEvent(LAYOUT, blocks))
97
+ target.emitEvent(new LayoutEvent(AFTER, blocks))
99
98
 
100
99
  this.setBlocks(blocks)
101
100
 
@@ -110,16 +109,16 @@ export class Layouter implements ILayouter {
110
109
  const t = Run.start('FullLayout')
111
110
 
112
111
  const { target } = this
113
- const { BEFORE_ONCE, ONCE, AFTER_ONCE } = LayoutEvent
112
+ const { BEFORE, LAYOUT, AFTER } = LayoutEvent
114
113
 
115
114
  const blocks = this.getBlocks(new LeafList(target))
116
- target.emitEvent(new LayoutEvent(BEFORE_ONCE, blocks))
115
+ target.emitEvent(new LayoutEvent(BEFORE, blocks))
117
116
 
118
117
  Layouter.fullLayout(target)
119
118
 
120
119
  blocks.forEach(item => { item.setAfter() })
121
- target.emitEvent(new LayoutEvent(ONCE, blocks))
122
- target.emitEvent(new LayoutEvent(AFTER_ONCE, blocks))
120
+ target.emitEvent(new LayoutEvent(LAYOUT, blocks))
121
+ target.emitEvent(new LayoutEvent(AFTER, blocks))
123
122
 
124
123
  this.setBlocks(blocks)
125
124
 
@@ -156,7 +155,7 @@ export class Layouter implements ILayouter {
156
155
  }
157
156
 
158
157
  protected __checkAgain(): void {
159
- if (this.changed && this.times <= this.config.partLayout.maxTimes) this.target.emit(LayoutEvent.AGAIN) // 防止更新布局过程中产生了属性修改
158
+ //if (this.changed && this.times <= this.config.partLayout.maxTimes) this.target.emit(LayoutEvent.AGAIN) // 防止更新布局过程中产生了属性修改
160
159
  }
161
160
 
162
161
  protected __onReceiveWatchData(event: WatchEvent): void {
@@ -179,6 +178,7 @@ export class Layouter implements ILayouter {
179
178
 
180
179
  public destroy(): void {
181
180
  if (this.target) {
181
+ this.stop()
182
182
  this.__removeListenEvents()
183
183
  this.target = null
184
184
  }
@@ -11,7 +11,7 @@ export function updateMatrix(updateList: ILeafList, levelList: ILeafLevelList):
11
11
  let layout: ILeafLayout
12
12
  updateList.list.forEach(leaf => { // 更新矩阵, 所有子元素,和父元素都需要更新bounds
13
13
  layout = leaf.__layout
14
- if (levelList.without(leaf)) { // 防止重复, 子元素可能已经被父元素更新过
14
+ if (levelList.without(leaf) && !layout.useZoomProxy) { // 防止重复, 子元素可能已经被父元素更新过
15
15
 
16
16
  if (layout.matrixChanged) {
17
17