@leafer-ui/image 1.9.7 → 1.9.8
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/check.ts +8 -10
- package/src/data.ts +6 -1
- package/src/mode.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/image",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.8",
|
|
4
4
|
"description": "@leafer-ui/image",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.9.
|
|
26
|
-
"@leafer-ui/draw": "1.9.
|
|
25
|
+
"@leafer/core": "1.9.8",
|
|
26
|
+
"@leafer-ui/draw": "1.9.8"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@leafer/interface": "1.9.
|
|
30
|
-
"@leafer-ui/interface": "1.9.
|
|
29
|
+
"@leafer/interface": "1.9.8",
|
|
30
|
+
"@leafer-ui/interface": "1.9.8"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/check.ts
CHANGED
|
@@ -18,17 +18,15 @@ export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, al
|
|
|
18
18
|
if (allowDraw) {
|
|
19
19
|
if (data.repeat) {
|
|
20
20
|
allowDraw = false
|
|
21
|
-
} else {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
height *= data.scaleY
|
|
29
|
-
}
|
|
30
|
-
allowDraw = (width * height > Platform.image.maxCacheSize)
|
|
21
|
+
} else if (!(paint.changeful || (Platform.name === 'miniapp' && ResizeEvent.isResizing(ui)) || Export.running)) { // 小程序resize过程中直接绘制原图(绕过垃圾回收bug)
|
|
22
|
+
let { width, height } = data
|
|
23
|
+
width *= scaleX * pixelRatio
|
|
24
|
+
height *= scaleY * pixelRatio
|
|
25
|
+
if (data.scaleX) {
|
|
26
|
+
width *= data.scaleX
|
|
27
|
+
height *= data.scaleY
|
|
31
28
|
}
|
|
29
|
+
allowDraw = (width * height > Platform.image.maxCacheSize)
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
package/src/data.ts
CHANGED
|
@@ -60,7 +60,12 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
|
|
|
60
60
|
break
|
|
61
61
|
case 'normal':
|
|
62
62
|
case 'clip':
|
|
63
|
-
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
63
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
64
|
+
let clipScaleX: number, clipScaleY: number
|
|
65
|
+
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height
|
|
66
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY)
|
|
67
|
+
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY
|
|
68
|
+
}
|
|
64
69
|
break
|
|
65
70
|
case 'repeat':
|
|
66
71
|
if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform)
|
package/src/mode.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBoundsData, IPointData, IMatrixData, IAlign
|
|
1
|
+
import { IBoundsData, IPointData, IMatrixData, IAlign } from '@leafer/interface'
|
|
2
2
|
import { getMatrixData, MatrixHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { ILeafPaintPatternData } from '@leafer-ui/interface'
|
|
@@ -15,11 +15,11 @@ export function fillOrFitMode(data: ILeafPaintPatternData, box: IBoundsData, x:
|
|
|
15
15
|
data.transform = transform
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number, skew: IPointData,
|
|
18
|
+
export function clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number, skew: IPointData, clipScaleX?: number, clipScaleY?: number): void {
|
|
19
19
|
const transform: IMatrixData = get()
|
|
20
20
|
layout(transform, box, x, y, scaleX, scaleY, rotation, skew)
|
|
21
|
-
if (
|
|
22
|
-
tempMatrix.a =
|
|
21
|
+
if (clipScaleX) {
|
|
22
|
+
tempMatrix.a = clipScaleX, tempMatrix.d = clipScaleY
|
|
23
23
|
multiplyParent(transform, tempMatrix)
|
|
24
24
|
}
|
|
25
25
|
data.transform = transform
|