@leafer/canvas-web 1.0.0-rc.1 → 1.0.0-rc.10
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 +5 -26
- package/types/index.d.ts +1 -3
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.10",
|
|
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.10"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.0-rc.
|
|
28
|
+
"@leafer/interface": "1.0.0-rc.10"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/LeaferCanvas.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IAutoBounds, ISizeData, IScreenSizeData, IResizeEventListener
|
|
2
|
-
import { LeaferCanvasBase, canvasSizeAttrs, ResizeEvent, DataHelper, Platform, Debug
|
|
1
|
+
import { IAutoBounds, ISizeData, IScreenSizeData, IResizeEventListener } from '@leafer/interface'
|
|
2
|
+
import { LeaferCanvasBase, canvasSizeAttrs, ResizeEvent, DataHelper, Platform, Debug } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const debug = Debug.get('LeaferCanvas')
|
|
@@ -20,6 +20,7 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
20
20
|
const { style } = this.view
|
|
21
21
|
style.display || (style.display = 'block')
|
|
22
22
|
this.parentView = this.view.parentElement
|
|
23
|
+
if (this.parentView) this.parentView.style.userSelect = 'none'
|
|
23
24
|
|
|
24
25
|
if (Platform.syncDomFont && !this.parentView) { // fix: firefox default font
|
|
25
26
|
this.view.style.display = 'none'
|
|
@@ -41,27 +42,6 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
41
42
|
this.view = document.createElement('canvas')
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
public setCursor(cursor: ICursorType | ICursorType[]): void {
|
|
45
|
-
const list: ICursorType[] = []
|
|
46
|
-
this.eachCursor(cursor, list)
|
|
47
|
-
if (typeof list[list.length - 1] === 'object') list.push('default')
|
|
48
|
-
this.view.style.cursor = list.map(item => (typeof item === 'object') ? `url(${item.url}) ${item.x || 0} ${item.y || 0}` : item).join(',')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected eachCursor(cursor: ICursorType | ICursorType[], list: ICursorType[], level = 0): void {
|
|
52
|
-
level++
|
|
53
|
-
if (cursor instanceof Array) {
|
|
54
|
-
cursor.forEach(item => this.eachCursor(item, list, level))
|
|
55
|
-
} else {
|
|
56
|
-
const custom = typeof cursor === 'string' && Cursor.get(cursor)
|
|
57
|
-
if (custom && level < 2) {
|
|
58
|
-
this.eachCursor(custom, list, level)
|
|
59
|
-
} else {
|
|
60
|
-
list.push(cursor)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
45
|
protected __createViewFrom(inputView: string | object): void {
|
|
66
46
|
let find: unknown = (typeof inputView === 'string') ? document.getElementById(inputView) : inputView as HTMLElement
|
|
67
47
|
if (find) {
|
|
@@ -106,9 +86,8 @@ export class LeaferCanvas extends LeaferCanvasBase {
|
|
|
106
86
|
style.width = width + 'px'
|
|
107
87
|
style.height = height + 'px'
|
|
108
88
|
|
|
109
|
-
this.view.width = width * pixelRatio
|
|
110
|
-
this.view.height = height * pixelRatio
|
|
111
|
-
|
|
89
|
+
this.view.width = Math.ceil(width * pixelRatio)
|
|
90
|
+
this.view.height = Math.ceil(height * pixelRatio)
|
|
112
91
|
}
|
|
113
92
|
|
|
114
93
|
public updateClientBounds(): void {
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAutoBounds, IResizeEventListener,
|
|
1
|
+
import { IAutoBounds, IResizeEventListener, ISizeData } from '@leafer/interface';
|
|
2
2
|
import { LeaferCanvasBase } from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
declare class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -13,8 +13,6 @@ declare class LeaferCanvas extends LeaferCanvasBase {
|
|
|
13
13
|
set hittable(hittable: boolean);
|
|
14
14
|
get hittable(): boolean;
|
|
15
15
|
protected __createView(): void;
|
|
16
|
-
setCursor(cursor: ICursorType | ICursorType[]): void;
|
|
17
|
-
protected eachCursor(cursor: ICursorType | ICursorType[], list: ICursorType[], level?: number): void;
|
|
18
16
|
protected __createViewFrom(inputView: string | object): void;
|
|
19
17
|
updateViewSize(): void;
|
|
20
18
|
updateClientBounds(): void;
|