@leafer/display 1.0.0-beta.4 → 1.0.0-beta.6

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/display",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.6",
4
4
  "description": "@leafer/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,15 +19,15 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/math": "1.0.0-beta.4",
23
- "@leafer/data": "1.0.0-beta.4",
24
- "@leafer/layout": "1.0.0-beta.4",
25
- "@leafer/display-module": "1.0.0-beta.4",
26
- "@leafer/event": "1.0.0-beta.4",
27
- "@leafer/decorator": "1.0.0-beta.4",
28
- "@leafer/helper": "1.0.0-beta.4"
22
+ "@leafer/math": "1.0.0-beta.6",
23
+ "@leafer/data": "1.0.0-beta.6",
24
+ "@leafer/layout": "1.0.0-beta.6",
25
+ "@leafer/display-module": "1.0.0-beta.6",
26
+ "@leafer/event": "1.0.0-beta.6",
27
+ "@leafer/decorator": "1.0.0-beta.6",
28
+ "@leafer/helper": "1.0.0-beta.6"
29
29
  },
30
30
  "devDependencies": {
31
- "@leafer/interface": "1.0.0-beta.4"
31
+ "@leafer/interface": "1.0.0-beta.6"
32
32
  }
33
33
  }
package/src/Branch.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { ILeaf, ILeaferCanvas, IRenderOptions } from '@leafer/interface'
1
+ import { ILeaf } from '@leafer/interface'
2
2
  import { ChildEvent } from '@leafer/event'
3
3
  import { BoundsHelper } from '@leafer/math'
4
4
  import { BranchHelper, LeafBoundsHelper, WaitHelper } from '@leafer/helper'
5
5
  import { useModule } from '@leafer/decorator'
6
- import { LeafMask } from '@leafer/display-module'
6
+ import { BranchRender, LeafMask } from '@leafer/display-module'
7
7
 
8
8
  import { Leaf } from './Leaf'
9
9
 
@@ -12,6 +12,8 @@ const { setByListWithHandle } = BoundsHelper
12
12
  const { sort } = BranchHelper
13
13
  const { localBoxBounds, localEventBounds, localRenderBounds, maskLocalBoxBounds, maskLocalEventBounds, maskLocalRenderBounds } = LeafBoundsHelper
14
14
 
15
+
16
+ @useModule(BranchRender)
15
17
  @useModule(LeafMask)
16
18
  export class Branch extends Leaf {
17
19
 
@@ -51,14 +53,6 @@ export class Branch extends Leaf {
51
53
  setByListWithHandle(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds)
52
54
  }
53
55
 
54
- public __updateChange(): void {
55
- const { __layout: layout } = this
56
- if (layout.childrenSortChanged) {
57
- this.__updateSortChildren()
58
- layout.childrenSortChanged = false
59
- }
60
- }
61
-
62
56
 
63
57
  // own
64
58
 
@@ -72,60 +66,6 @@ export class Branch extends Leaf {
72
66
  }
73
67
  }
74
68
 
75
- public __render(canvas: ILeaferCanvas, options: IRenderOptions): void {
76
-
77
- if (this.__worldOpacity) {
78
-
79
- let child: ILeaf
80
- const { children } = this
81
-
82
- if (this.__hasMask && children.length > 1) {
83
-
84
- let mask: boolean
85
- let maskCanvas = canvas.getSameCanvas()
86
- let contentCanvas = canvas.getSameCanvas()
87
-
88
- for (let i = 0, len = children.length; i < len; i++) {
89
- child = children[i]
90
-
91
- if (child.isMask) {
92
- if (mask) {
93
- this.__renderMask(canvas, contentCanvas, maskCanvas)
94
- maskCanvas.clear()
95
- contentCanvas.clear()
96
- } else {
97
- mask = true
98
- }
99
-
100
- child.__render(maskCanvas, options)
101
- continue
102
- }
103
-
104
- child.__render(contentCanvas, options)
105
- }
106
-
107
- this.__renderMask(canvas, contentCanvas, maskCanvas)
108
- maskCanvas.recycle()
109
- contentCanvas.recycle()
110
-
111
- } else {
112
-
113
- const { bounds, hideBounds } = options
114
-
115
- for (let i = 0, len = children.length; i < len; i++) {
116
- child = children[i]
117
-
118
- if (bounds && !bounds.hit(child.__world, options.matrix)) continue
119
- if (hideBounds && hideBounds.includes(child.__world, options.matrix)) continue
120
-
121
- child.__render(canvas, options)
122
- }
123
-
124
- }
125
- }
126
-
127
- }
128
-
129
69
  public add(child: ILeaf, index?: number): void {
130
70
 
131
71
  if (child.parent) child.parent.remove(child)
package/src/Leaf.ts CHANGED
@@ -4,7 +4,7 @@ import { LeafData } from '@leafer/data'
4
4
  import { LeafLayout } from '@leafer/layout'
5
5
  import { LeafDataProxy, LeafMatrix, LeafBounds, LeafHit, LeafEventer, LeafRender } from '@leafer/display-module'
6
6
  import { useModule } from '@leafer/decorator'
7
- import { WaitHelper } from '@leafer/helper'
7
+ import { LeafHelper, WaitHelper } from '@leafer/helper'
8
8
 
9
9
 
10
10
  const { LEAF, create } = IncrementId
@@ -58,10 +58,11 @@ export class Leaf implements ILeaf {
58
58
  public __tempNumber: number // temp sort
59
59
 
60
60
  public __hasMask?: boolean
61
+ public __hasEraser?: boolean
61
62
  public __hitCanvas?: IHitCanvas
62
63
 
63
64
  public get __onlyHitMask(): boolean { return this.__hasMask && !this.__.hitChildren }
64
- public get __ignoreHitWorld(): boolean { return this.__hasMask && this.__.hitChildren }
65
+ public get __ignoreHitWorld(): boolean { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren }
65
66
 
66
67
  // event
67
68
  public __captureMap?: IEventListenerMap
@@ -90,11 +91,11 @@ export class Leaf implements ILeaf {
90
91
 
91
92
 
92
93
  public waitParent(item: IFunction): void {
93
- this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]
94
+ this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item])
94
95
  }
95
96
 
96
97
  public waitLeafer(item: IFunction): void {
97
- this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item]
98
+ this.leafer ? item() : (this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item])
98
99
  }
99
100
 
100
101
 
@@ -174,7 +175,9 @@ export class Leaf implements ILeaf {
174
175
 
175
176
  // LeafMask rewrite
176
177
 
177
- public __updateMask(): void { }
178
+ public __updateEraser(_value?: boolean): void { }
179
+
180
+ public __updateMask(_value?: boolean): void { }
178
181
 
179
182
  public __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void { }
180
183
 
@@ -219,6 +222,24 @@ export class Leaf implements ILeaf {
219
222
  }
220
223
 
221
224
 
225
+ // transform
226
+
227
+ public move(x: number, y?: number): void {
228
+ LeafHelper.moveLocal(this, x, y)
229
+ }
230
+
231
+ public scaleOf(origin: IPointData, x: number, y?: number): void {
232
+ this.__layout.checkUpdate()
233
+ if (y === undefined) y = x
234
+ LeafHelper.zoomOfLocal(this, PointHelper.tempToOuterOf(origin, this.__local), x, y)
235
+ }
236
+
237
+ public rotateOf(origin: IPointData, angle: number): void {
238
+ this.__layout.checkUpdate()
239
+ LeafHelper.rotateOfLocal(this, PointHelper.tempToOuterOf(origin, this.__local), angle)
240
+ }
241
+
242
+
222
243
  // LeafHit rewrite
223
244
 
224
245
  public __hitWorld(_point: IRadiusPointData): boolean { return true }