@leafer/canvas-web 1.12.0 → 1.12.2
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 +3 -3
- package/src/LeaferCanvas.ts +13 -30
- package/types/index.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/canvas-web",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "@leafer/canvas-web",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.12.
|
|
25
|
+
"@leafer/core": "1.12.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.12.
|
|
28
|
+
"@leafer/interface": "1.12.2"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/LeaferCanvas.ts
CHANGED
|
@@ -28,10 +28,6 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// CSS 原始自动宽高值
|
|
32
|
-
protected autoWidthStr: string
|
|
33
|
-
protected autoHeightStr: string
|
|
34
|
-
|
|
35
31
|
protected resizeObserver: ResizeObserver
|
|
36
32
|
protected autoBounds: IAutoBounds
|
|
37
33
|
protected resizeListener: IResizeEventListener
|
|
@@ -49,6 +45,7 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
49
45
|
if (this.parentView) {
|
|
50
46
|
const pStyle = this.parentView.style
|
|
51
47
|
pStyle.webkitUserSelect = pStyle.userSelect = 'none' // fix safari: use webkitUserSelect
|
|
48
|
+
this.view.classList.add('leafer-canvas-view')
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
if (Platform.syncDomFont && !this.parentView) { // fix: firefox default font
|
|
@@ -116,27 +113,12 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
116
113
|
const { width, height, pixelRatio } = this
|
|
117
114
|
const { style } = this.view
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const { config, autoWidthStr, autoHeightStr } = this
|
|
122
|
-
if (config.width) {
|
|
123
|
-
if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || ''
|
|
124
|
-
style.width = config.width + 'px'
|
|
125
|
-
} else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr
|
|
126
|
-
|
|
127
|
-
if (config.height) {
|
|
128
|
-
if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || ''
|
|
129
|
-
style.height = config.height + 'px'
|
|
130
|
-
} else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr
|
|
131
|
-
|
|
132
|
-
} else {
|
|
133
|
-
|
|
134
|
-
style.width = width + 'px'
|
|
135
|
-
style.height = height + 'px'
|
|
116
|
+
style.width = width + 'px'
|
|
117
|
+
style.height = height + 'px'
|
|
136
118
|
|
|
119
|
+
if (!this.unreal) {
|
|
137
120
|
this.view.width = Math.ceil(width * pixelRatio)
|
|
138
121
|
this.view.height = Math.ceil(height * pixelRatio)
|
|
139
|
-
|
|
140
122
|
}
|
|
141
123
|
}
|
|
142
124
|
|
|
@@ -240,23 +222,24 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
240
222
|
|
|
241
223
|
|
|
242
224
|
public unrealCanvas(): void { // App needs to use
|
|
243
|
-
if (!this.unreal && this.parentView) {
|
|
244
|
-
|
|
225
|
+
if (!this.unreal && this.parentView) { // canvas 替换成 div, 方便放入子canvas
|
|
226
|
+
let view = this.view
|
|
245
227
|
if (view) view.remove()
|
|
246
228
|
|
|
247
|
-
this.view =
|
|
229
|
+
view = this.view = document.createElement('div') as any
|
|
230
|
+
this.parentView.appendChild(this.view)
|
|
231
|
+
view.classList.add('leafer-app-view')
|
|
232
|
+
|
|
248
233
|
this.unreal = true
|
|
249
234
|
}
|
|
250
235
|
}
|
|
251
236
|
|
|
252
237
|
public destroy(): void {
|
|
253
|
-
|
|
238
|
+
const { view } = this
|
|
239
|
+
if (view) {
|
|
254
240
|
this.stopAutoLayout()
|
|
255
241
|
this.stopListenPixelRatio()
|
|
256
|
-
if (
|
|
257
|
-
const view = this.view
|
|
258
|
-
if (view.parentElement) view.remove()
|
|
259
|
-
}
|
|
242
|
+
if (view.parentElement) view.remove()
|
|
260
243
|
super.destroy()
|
|
261
244
|
}
|
|
262
245
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ declare class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6
6
|
parentView: HTMLElement;
|
|
7
7
|
set zIndex(zIndex: number);
|
|
8
8
|
set childIndex(index: number);
|
|
9
|
-
protected autoWidthStr: string;
|
|
10
|
-
protected autoHeightStr: string;
|
|
11
9
|
protected resizeObserver: ResizeObserver;
|
|
12
10
|
protected autoBounds: IAutoBounds;
|
|
13
11
|
protected resizeListener: IResizeEventListener;
|