@leafer-ui/paint 1.0.0-beta.8 → 1.0.0-beta.9
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 +5 -5
- package/src/paint/image.ts +6 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/paint",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "@leafer-ui/paint",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/core": "1.0.0-beta.
|
|
23
|
-
"@leafer-ui/color": "1.0.0-beta.
|
|
22
|
+
"@leafer/core": "1.0.0-beta.9",
|
|
23
|
+
"@leafer-ui/color": "1.0.0-beta.9"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@leafer/interface": "1.0.0-beta.
|
|
27
|
-
"@leafer-ui/interface": "1.0.0-beta.
|
|
26
|
+
"@leafer/interface": "1.0.0-beta.9",
|
|
27
|
+
"@leafer-ui/interface": "1.0.0-beta.9"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/paint/image.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
43
43
|
if (!sameBox || rotation) transform = getFillOrFitTransform(mode, box, width, height, rotation)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
leaferPaint
|
|
46
|
+
createPattern(leaferPaint, image.getCanvas(width, height, opacity), transform, mode === 'repeat')
|
|
47
47
|
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -53,11 +53,11 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, box: IBound
|
|
|
53
53
|
() => {
|
|
54
54
|
if (ui.leafer) {
|
|
55
55
|
if (hasSize(ui, attrName, image)) ui.forceUpdate('width')
|
|
56
|
-
ui.emitEvent(new ImageEvent(ImageEvent.LOADED, ui, image, attrName, paint))
|
|
56
|
+
if (ui.hasEvent(ImageEvent.LOADED)) ui.emitEvent(new ImageEvent(ImageEvent.LOADED, ui, image, attrName, paint))
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
(error) => {
|
|
60
|
-
ui.emitEvent(new ImageEvent(ImageEvent.ERROR, ui, image, attrName, paint, error))
|
|
60
|
+
if (ui.hasEvent(ImageEvent.ERROR)) ui.emitEvent(new ImageEvent(ImageEvent.ERROR, ui, image, attrName, paint, error))
|
|
61
61
|
}
|
|
62
62
|
)
|
|
63
63
|
|
|
@@ -129,11 +129,8 @@ function getRepeatTransform(box: IBoundsData, width: number, height: number, sca
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
function createPattern(canvas: any, transform?: IMatrixData, repeat?: boolean
|
|
132
|
+
function createPattern(paint: ILeafPaint, canvas: any, transform?: IMatrixData, repeat?: boolean): void {
|
|
133
133
|
let style = Platform.canvas.createPattern(canvas, repeat ? 'repeat' : 'no-repeat')
|
|
134
|
-
if (transform)
|
|
135
|
-
|
|
136
|
-
style.setTransform(new DOMMatrix([a, b, c, d, e, f]))
|
|
137
|
-
}
|
|
138
|
-
return style
|
|
134
|
+
if (transform) style.setTransform ? style.setTransform(transform) : paint.transform = transform
|
|
135
|
+
paint.style = style
|
|
139
136
|
}
|