@leafer/canvas-web 1.0.0-rc.26 → 1.0.0-rc.28
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 +26 -3
- package/types/index.d.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/canvas-web",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.28",
|
|
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.0.0-rc.
|
|
25
|
+
"@leafer/core": "1.0.0-rc.28"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.0-rc.
|
|
28
|
+
"@leafer/interface": "1.0.0-rc.28"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/LeaferCanvas.ts
CHANGED
|
@@ -9,6 +9,25 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
9
9
|
declare public view: HTMLCanvasElement
|
|
10
10
|
declare public parentView: HTMLElement
|
|
11
11
|
|
|
12
|
+
public set zIndex(zIndex: number) {
|
|
13
|
+
const { style } = this.view
|
|
14
|
+
style.zIndex = zIndex as unknown as string
|
|
15
|
+
this.setAbsolute(this.view)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public set childIndex(index: number) {
|
|
19
|
+
const { view, parentView } = this
|
|
20
|
+
if (view && parentView) {
|
|
21
|
+
const beforeNode = parentView.children[index]
|
|
22
|
+
if (beforeNode) {
|
|
23
|
+
this.setAbsolute(beforeNode as HTMLCanvasElement)
|
|
24
|
+
parentView.insertBefore(view, beforeNode)
|
|
25
|
+
} else {
|
|
26
|
+
parentView.appendChild(beforeNode)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
12
31
|
protected resizeObserver: ResizeObserver
|
|
13
32
|
protected autoBounds: IAutoBounds
|
|
14
33
|
protected resizeListener: IResizeEventListener
|
|
@@ -69,9 +88,7 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
69
88
|
const view = this.view
|
|
70
89
|
|
|
71
90
|
if (parent.hasChildNodes()) {
|
|
72
|
-
|
|
73
|
-
style.position = 'absolute'
|
|
74
|
-
style.top = style.left = '0px'
|
|
91
|
+
this.setAbsolute(view)
|
|
75
92
|
parent.style.position || (parent.style.position = 'relative')
|
|
76
93
|
}
|
|
77
94
|
|
|
@@ -83,6 +100,12 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
102
|
|
|
103
|
+
protected setAbsolute(view: HTMLCanvasElement): void {
|
|
104
|
+
const { style } = view
|
|
105
|
+
style.position = 'absolute'
|
|
106
|
+
style.top = style.left = '0px'
|
|
107
|
+
}
|
|
108
|
+
|
|
86
109
|
public updateViewSize(): void {
|
|
87
110
|
const { width, height, pixelRatio } = this
|
|
88
111
|
|
package/types/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { LeaferCanvasBase } from '@leafer/core';
|
|
|
4
4
|
declare class LeaferCanvas extends LeaferCanvasBase {
|
|
5
5
|
view: HTMLCanvasElement;
|
|
6
6
|
parentView: HTMLElement;
|
|
7
|
+
set zIndex(zIndex: number);
|
|
8
|
+
set childIndex(index: number);
|
|
7
9
|
protected resizeObserver: ResizeObserver;
|
|
8
10
|
protected autoBounds: IAutoBounds;
|
|
9
11
|
protected resizeListener: IResizeEventListener;
|
|
@@ -14,6 +16,7 @@ declare class LeaferCanvas extends LeaferCanvasBase {
|
|
|
14
16
|
get hittable(): boolean;
|
|
15
17
|
protected __createView(): void;
|
|
16
18
|
protected __createViewFrom(inputView: string | object): void;
|
|
19
|
+
protected setAbsolute(view: HTMLCanvasElement): void;
|
|
17
20
|
updateViewSize(): void;
|
|
18
21
|
updateClientBounds(): void;
|
|
19
22
|
startAutoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void;
|