@leafer/display-module 1.0.0-alpha.1 → 1.0.0-alpha.21

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,11 +1,13 @@
1
1
  {
2
2
  "name": "@leafer/display-module",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.21",
4
4
  "description": "@leafer/display-module",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
- "files": ["src"],
8
+ "files": [
9
+ "src"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/leaferjs/leafer.git"
@@ -17,10 +19,10 @@
17
19
  "leaferjs"
18
20
  ],
19
21
  "dependencies": {
20
- "@leafer/event": "1.0.0-alpha.1",
21
- "@leafer/math": "1.0.0-alpha.1"
22
+ "@leafer/event": "1.0.0-alpha.21",
23
+ "@leafer/math": "1.0.0-alpha.21"
22
24
  },
23
25
  "devDependencies": {
24
- "@leafer/interface": "1.0.0-alpha.1"
26
+ "@leafer/interface": "1.0.0-alpha.21"
25
27
  }
26
- }
28
+ }
package/src/LeafBounds.ts CHANGED
@@ -2,7 +2,7 @@ import { ILeafBoundsModule } from '@leafer/interface'
2
2
  import { BoundsHelper } from '@leafer/math'
3
3
 
4
4
 
5
- const { setByBoundsTimesMatrix } = BoundsHelper
5
+ const { toWorld, copyAndSpread } = BoundsHelper
6
6
 
7
7
  export const LeafBounds: ILeafBoundsModule = {
8
8
 
@@ -85,26 +85,26 @@ export const LeafBounds: ILeafBoundsModule = {
85
85
 
86
86
  layout.boundsChanged = false
87
87
 
88
- setByBoundsTimesMatrix(this.__world, this.__layout.renderBounds, this.__world)
88
+ toWorld(this.__layout.renderBounds, this.__world, this.__world)
89
89
 
90
90
  if (resize) this.__onUpdateSize()
91
91
 
92
92
  } else {
93
- setByBoundsTimesMatrix(this.__world, this.__layout.renderBounds, this.__world)
93
+ toWorld(this.__layout.renderBounds, this.__world, this.__world)
94
94
  }
95
95
 
96
96
  },
97
97
 
98
98
  __updateRelativeBoxBounds(): void {
99
- setByBoundsTimesMatrix(this.__relative, this.__layout.boxBounds, this.__relative)
99
+ toWorld(this.__layout.boxBounds, this.__relative, this.__relative)
100
100
  },
101
101
 
102
102
  __updateRelativeEventBounds(): void {
103
- setByBoundsTimesMatrix(this.__layout.relativeEventBounds, this.__layout.eventBounds, this.__relative)
103
+ toWorld(this.__layout.eventBounds, this.__relative, this.__layout.relativeEventBounds)
104
104
  },
105
105
 
106
106
  __updateRelativeRenderBounds(): void {
107
- setByBoundsTimesMatrix(this.__layout.relativeRenderBounds, this.__layout.renderBounds, this.__relative)
107
+ toWorld(this.__layout.renderBounds, this.__relative, this.__layout.relativeRenderBounds)
108
108
  },
109
109
 
110
110
 
@@ -114,6 +114,14 @@ export const LeafBounds: ILeafBoundsModule = {
114
114
  b.y = 0
115
115
  b.width = this.__.width
116
116
  b.height = this.__.height
117
- }
117
+ },
118
+
119
+ __updateEventBounds(): void {
120
+ copyAndSpread(this.__layout.eventBounds, this.__layout.boxBounds, this.__layout.eventBoundsSpreadWidth)
121
+ },
122
+
123
+ __updateRenderBounds(): void {
124
+ copyAndSpread(this.__layout.renderBounds, this.__layout.eventBounds, this.__layout.renderBoundsSpreadWidth)
125
+ },
118
126
 
119
127
  }
@@ -5,10 +5,14 @@ import { AttrEvent } from '@leafer/event'
5
5
  export const LeafDataProxy: ILeafDataProxyModule = {
6
6
 
7
7
  __set(attrName: string, newValue: unknown): void {
8
- const oldValue = this.__.__getInput(attrName)
9
- if (oldValue !== newValue) {
8
+ if (this.root) {
9
+ const oldValue = this.__.__getInput(attrName)
10
+ if (oldValue !== newValue) {
11
+ this.__[attrName] = newValue
12
+ this.root.emitEvent(new AttrEvent(AttrEvent.CHANGE, this, attrName, oldValue, newValue))
13
+ }
14
+ } else {
10
15
  this.__[attrName] = newValue
11
- this.root.emitEvent(new AttrEvent(AttrEvent.CHANGE, this, attrName, oldValue, newValue))
12
16
  }
13
17
  },
14
18
 
@@ -17,8 +21,10 @@ export const LeafDataProxy: ILeafDataProxyModule = {
17
21
  },
18
22
 
19
23
  __updateAttr(attrName: string): void {
20
- const value = this.__.__getInput(attrName)
21
- this.root?.emitEvent(new AttrEvent(AttrEvent.CHANGE, this, attrName, value, value))
24
+ if (this.root) {
25
+ const value = this.__.__getInput(attrName)
26
+ this.root.emitEvent(new AttrEvent(AttrEvent.CHANGE, this, attrName, value, value))
27
+ }
22
28
  }
23
29
 
24
30
  }
@@ -1,6 +1,7 @@
1
1
  import { IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId, IEvent, IObject, IEventTarget, ILeafEventerModule } from '@leafer/interface'
2
+ import { Debug } from '@leafer/debug'
2
3
 
3
-
4
+ const debug = Debug.get('Life')
4
5
  const empty = {}
5
6
 
6
7
  export const LeafEventer: ILeafEventerModule = {
@@ -70,6 +71,8 @@ export const LeafEventer: ILeafEventerModule = {
70
71
  },
71
72
 
72
73
  emit(type: string, event?: IEvent | IObject, capture?: boolean): void {
74
+ if (Debug.enable) debug.log(type)
75
+
73
76
  const map = __getListenerMap(this, capture)
74
77
  const list = map[type]
75
78
  if (list) {
@@ -77,7 +80,10 @@ export const LeafEventer: ILeafEventerModule = {
77
80
  for (let i = 0, len = list.length; i < len; i++) {
78
81
  item = list[i]
79
82
  item.listener(event)
80
- if (item.once) this.off(type, item.listener, capture)
83
+ if (item.once) {
84
+ this.off(type, item.listener, capture)
85
+ i--, len--
86
+ }
81
87
  if (event && (event as IEvent).isStopNow) break
82
88
  }
83
89
  }
package/src/LeafHit.ts CHANGED
@@ -3,7 +3,7 @@ import { PointHelper } from '@leafer/math'
3
3
 
4
4
 
5
5
  const { toLocalRadiusPoint } = PointHelper
6
- const innerPoint = {} as IRadiusPointData
6
+ const local = {} as IRadiusPointData
7
7
 
8
8
  export const LeafHit: ILeafHitModule = {
9
9
 
@@ -17,8 +17,8 @@ export const LeafHit: ILeafHitModule = {
17
17
  this.__updateHitCanvas()
18
18
  this.__layout.hitCanvasChanged = false
19
19
  }
20
- toLocalRadiusPoint(point, this.__world, innerPoint)
21
- return this.__hit(innerPoint)
20
+ toLocalRadiusPoint(point, this.__world, local)
21
+ return this.__hit(local)
22
22
  }
23
23
 
24
24
  }
package/src/LeafRender.ts CHANGED
@@ -7,7 +7,7 @@ export const LeafRender: ILeafRenderModule = {
7
7
  if (this.__worldOpacity) {
8
8
  canvas.setWorld(this.__world, options.matrix)
9
9
  canvas.opacity = this.__worldOpacity
10
- this.__complex ? this.__draw(canvas, options) : this.__drawFast(canvas, options)
10
+ this.__draw(canvas, options)
11
11
  }
12
12
  },
13
13