@leafer/display-module 1.0.0-rc.22 → 1.0.0-rc.24
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 +6 -6
- package/src/BranchRender.ts +2 -0
- package/src/LeafBounds.ts +27 -17
- package/src/LeafEventer.ts +38 -15
- package/src/LeafMatrix.ts +7 -7
- package/src/LeafRender.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display-module",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.24",
|
|
4
4
|
"description": "@leafer/display-module",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/helper": "1.0.0-rc.
|
|
26
|
-
"@leafer/event": "1.0.0-rc.
|
|
27
|
-
"@leafer/math": "1.0.0-rc.
|
|
28
|
-
"@leafer/debug": "1.0.0-rc.
|
|
25
|
+
"@leafer/helper": "1.0.0-rc.24",
|
|
26
|
+
"@leafer/event": "1.0.0-rc.24",
|
|
27
|
+
"@leafer/math": "1.0.0-rc.24",
|
|
28
|
+
"@leafer/debug": "1.0.0-rc.24"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@leafer/interface": "1.0.0-rc.
|
|
31
|
+
"@leafer/interface": "1.0.0-rc.24"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/BranchRender.ts
CHANGED
|
@@ -22,6 +22,8 @@ export const BranchRender: IBranchRenderModule = {
|
|
|
22
22
|
|
|
23
23
|
if (this.__.__single) {
|
|
24
24
|
|
|
25
|
+
if (this.__.eraser === 'path') return this.__renderEraser(canvas, options)
|
|
26
|
+
|
|
25
27
|
const tempCanvas = canvas.getSameCanvas(false, true)
|
|
26
28
|
|
|
27
29
|
this.__renderBranch(tempCanvas, options)
|
package/src/LeafBounds.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { PathBounds } from '@leafer/path'
|
|
|
4
4
|
import { BranchHelper, LeafHelper } from '@leafer/helper'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const { updateMatrix, updateAllMatrix
|
|
7
|
+
const { updateMatrix, updateAllMatrix } = LeafHelper
|
|
8
8
|
const { updateBounds } = BranchHelper
|
|
9
9
|
const { toOuterOf, copyAndSpread, copy } = BoundsHelper
|
|
10
10
|
const { toBounds } = PathBounds
|
|
@@ -32,7 +32,6 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
32
32
|
this.__updateRenderPath()
|
|
33
33
|
|
|
34
34
|
this.__updateBoxBounds()
|
|
35
|
-
layout.boxChanged = false
|
|
36
35
|
layout.resized = true
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -48,15 +47,16 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
|
|
50
|
+
layout.boxChanged = false // must after updateLocalBoxBounds()
|
|
51
|
+
|
|
52
|
+
|
|
51
53
|
if (layout.strokeChanged) {
|
|
52
54
|
|
|
53
55
|
layout.strokeSpread = this.__updateStrokeSpread()
|
|
54
56
|
|
|
55
57
|
if (layout.strokeSpread) {
|
|
56
58
|
|
|
57
|
-
if (layout.strokeBounds === layout.boxBounds)
|
|
58
|
-
layout.spreadStroke()
|
|
59
|
-
}
|
|
59
|
+
if (layout.strokeBounds === layout.boxBounds) layout.spreadStroke()
|
|
60
60
|
|
|
61
61
|
this.__updateStrokeBounds()
|
|
62
62
|
this.__updateLocalStrokeBounds()
|
|
@@ -66,7 +66,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
layout.strokeChanged = false
|
|
69
|
-
if (layout.renderSpread) layout.renderChanged = true
|
|
69
|
+
if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread) layout.renderChanged = true
|
|
70
70
|
|
|
71
71
|
if (this.parent) this.parent.__layout.strokeChange()
|
|
72
72
|
layout.resized = true
|
|
@@ -79,9 +79,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
79
79
|
|
|
80
80
|
if (layout.renderSpread) {
|
|
81
81
|
|
|
82
|
-
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds)
|
|
83
|
-
layout.spreadRender()
|
|
84
|
-
}
|
|
82
|
+
if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) layout.spreadRender()
|
|
85
83
|
|
|
86
84
|
this.__updateRenderBounds()
|
|
87
85
|
this.__updateLocalRenderBounds()
|
|
@@ -100,7 +98,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
100
98
|
},
|
|
101
99
|
|
|
102
100
|
__updateLocalBoxBounds(): void {
|
|
103
|
-
if (this.__hasAutoLayout) this.__updateAutoLayout()
|
|
101
|
+
if (this.__hasAutoLayout) this.__updateAutoLayout() // origin / around / flow
|
|
104
102
|
toOuterOf(this.__layout.boxBounds, this.__local, this.__local)
|
|
105
103
|
},
|
|
106
104
|
|
|
@@ -130,13 +128,24 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
130
128
|
__updateAutoLayout(): void {
|
|
131
129
|
this.__layout.matrixChanged = true
|
|
132
130
|
if (this.isBranch) {
|
|
133
|
-
if (this.leafer) this.leafer.layouter.addExtra(this) // add part
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
if (this.leafer && this.leafer.ready) this.leafer.layouter.addExtra(this) // add part
|
|
132
|
+
|
|
133
|
+
if (this.__.flow) {
|
|
134
|
+
|
|
135
|
+
if (this.__layout.boxChanged) this.__updateFlowLayout()
|
|
136
|
+
|
|
137
|
+
updateAllMatrix(this)
|
|
138
|
+
updateBounds(this, this)
|
|
139
|
+
|
|
140
|
+
if (this.__.__autoSide) this.__updateBoxBounds()
|
|
141
|
+
|
|
136
142
|
} else {
|
|
143
|
+
|
|
137
144
|
updateAllMatrix(this)
|
|
138
145
|
updateBounds(this, this)
|
|
146
|
+
|
|
139
147
|
}
|
|
148
|
+
|
|
140
149
|
} else {
|
|
141
150
|
updateMatrix(this)
|
|
142
151
|
}
|
|
@@ -149,12 +158,13 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
149
158
|
},
|
|
150
159
|
|
|
151
160
|
__updateStrokeBounds(): void {
|
|
152
|
-
|
|
161
|
+
const layout = this.__layout
|
|
162
|
+
copyAndSpread(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread)
|
|
153
163
|
},
|
|
154
164
|
|
|
155
165
|
__updateRenderBounds(): void {
|
|
156
|
-
const
|
|
157
|
-
renderSpread > 0 ? copyAndSpread(renderBounds,
|
|
158
|
-
}
|
|
166
|
+
const layout = this.__layout
|
|
167
|
+
layout.renderSpread > 0 ? copyAndSpread(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy(layout.renderBounds, layout.strokeBounds) // Box use -1
|
|
168
|
+
}
|
|
159
169
|
|
|
160
170
|
}
|
package/src/LeafEventer.ts
CHANGED
|
@@ -33,24 +33,47 @@ export const LeafEventer: ILeafEventerModule = {
|
|
|
33
33
|
})
|
|
34
34
|
},
|
|
35
35
|
|
|
36
|
-
off(type
|
|
37
|
-
|
|
38
|
-
if (options) capture = typeof options === 'boolean' ? options : options.capture
|
|
36
|
+
off(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void {
|
|
37
|
+
if (type) {
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type
|
|
40
|
+
|
|
41
|
+
if (listener) {
|
|
42
|
+
|
|
43
|
+
let capture: boolean
|
|
44
|
+
if (options) capture = typeof options === 'boolean' ? options : options.capture
|
|
45
|
+
|
|
46
|
+
let events: IEventListenerItem[], index: number
|
|
47
|
+
const map = __getListenerMap(this, capture)
|
|
48
|
+
|
|
49
|
+
typeList.forEach(type => {
|
|
50
|
+
if (type) {
|
|
51
|
+
events = map[type]
|
|
52
|
+
if (events) {
|
|
53
|
+
index = events.findIndex(item => item.listener === listener)
|
|
54
|
+
if (index > -1) events.splice(index, 1)
|
|
55
|
+
if (!events.length) delete map[type]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
} else {
|
|
61
|
+
|
|
62
|
+
// off type
|
|
63
|
+
const { __bubbleMap: b, __captureMap: c } = this
|
|
64
|
+
typeList.forEach(type => {
|
|
65
|
+
if (b) delete b[type]
|
|
66
|
+
if (c) delete c[type]
|
|
67
|
+
})
|
|
43
68
|
|
|
44
|
-
typeList.forEach(type => {
|
|
45
|
-
if (type) {
|
|
46
|
-
events = map[type]
|
|
47
|
-
if (events) {
|
|
48
|
-
index = events.findIndex(item => item.listener === listener)
|
|
49
|
-
if (index > -1) events.splice(index, 1)
|
|
50
|
-
if (!events.length) delete map[type]
|
|
51
|
-
}
|
|
52
69
|
}
|
|
53
|
-
|
|
70
|
+
|
|
71
|
+
} else {
|
|
72
|
+
|
|
73
|
+
this.__bubbleMap = this.__captureMap = undefined // off all
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
54
77
|
},
|
|
55
78
|
|
|
56
79
|
on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId {
|
package/src/LeafMatrix.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeafMatrixModule, ILayoutData } from '@leafer/interface'
|
|
1
|
+
import { ILeafMatrixModule, ILayoutData, IScrollPointData } from '@leafer/interface'
|
|
2
2
|
import { AroundHelper, MatrixHelper } from '@leafer/math'
|
|
3
3
|
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
9
9
|
|
|
10
10
|
__updateWorldMatrix(): void {
|
|
11
11
|
|
|
12
|
-
multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__ as ILayoutData)
|
|
12
|
+
multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__ as ILayoutData, this.parent && this.parent.__ as IScrollPointData)
|
|
13
13
|
|
|
14
14
|
},
|
|
15
15
|
|
|
@@ -28,12 +28,12 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
local.e = data.x
|
|
32
|
-
local.f = data.y
|
|
31
|
+
local.e = data.x + data.offsetX
|
|
32
|
+
local.f = data.y + data.offsetY
|
|
33
33
|
|
|
34
|
-
if (data.around) {
|
|
35
|
-
toPoint(data.around, layout.boxBounds, tempPoint)
|
|
36
|
-
translateInner(local, -tempPoint.x, -tempPoint.y)
|
|
34
|
+
if (data.around || data.origin) {
|
|
35
|
+
toPoint(data.around || data.origin, layout.boxBounds, tempPoint)
|
|
36
|
+
translateInner(local, -tempPoint.x, -tempPoint.y, data.origin as unknown as boolean)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
}
|
package/src/LeafRender.ts
CHANGED