@leafer-ui/image 1.0.0-rc.18 → 1.0.0-rc.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/image",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.20",
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.0.0-rc.18",
26
- "@leafer/draw": "1.0.0-rc.18"
25
+ "@leafer/core": "1.0.0-rc.20",
26
+ "@leafer-ui/draw": "1.0.0-rc.20"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.18",
30
- "@leafer-ui/interface": "1.0.0-rc.18"
29
+ "@leafer/interface": "1.0.0-rc.20",
30
+ "@leafer-ui/interface": "1.0.0-rc.20"
31
31
  }
32
32
  }
package/src/check.ts CHANGED
@@ -10,7 +10,7 @@ import { createPattern } from './pattern'
10
10
  const { abs } = Math
11
11
 
12
12
  export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, allowPaint?: boolean): boolean {
13
- const { scaleX, scaleY } = ui.__nowWorld
13
+ const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld
14
14
 
15
15
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
16
16
  return false
package/src/data.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IBoundsData, ILeaferImage } from '@leafer/interface'
2
- import { MatrixHelper } from '@leafer/core'
2
+ import { MatrixHelper, Bounds } from '@leafer/core'
3
3
 
4
4
  import { IImagePaint, ILeafPaint, ILeafPaintPatternData } from '@leafer-ui/interface'
5
5
 
@@ -7,9 +7,11 @@ import { clipMode, fillOrFitMode, repeatMode } from './mode'
7
7
 
8
8
 
9
9
  const { get, translate } = MatrixHelper
10
+ const tempBox = new Bounds()
10
11
 
11
12
  export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void {
12
13
  let { width, height } = image
14
+ if (paint.padding) box = tempBox.set(box).shrink(paint.padding)
13
15
 
14
16
  const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint
15
17
  const sameBox = box.width === width && box.height === height
package/src/image.ts CHANGED
@@ -24,7 +24,7 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds:
24
24
  } else {
25
25
  leafPaint = { type: paint.type, image }
26
26
 
27
- cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null
27
+ cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null // 只保留最后一个cache
28
28
  }
29
29
 
30
30
  if (firstUse || image.loading) event = { image, attrName, attrValue: paint }
@@ -52,7 +52,10 @@ export function image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds:
52
52
  () => {
53
53
  ignoreRender(ui, false)
54
54
  if (!ui.destroyed) {
55
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) ui.forceUpdate('surface')
55
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
56
+ if (image.hasOpacityPixel) ui.__layout.hitCanvasChanged = true
57
+ ui.forceUpdate('surface')
58
+ }
56
59
  onLoadSuccess(ui, event)
57
60
  }
58
61
  leafPaint.loadId = null
package/src/pattern.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Platform, MatrixHelper } from '@leafer/core'
1
+ import { Platform, MatrixHelper, ImageManager } from '@leafer/core'
2
2
 
3
3
  import { IUI, ILeafPaint, IMatrixData } from '@leafer-ui/interface'
4
4
 
@@ -8,7 +8,7 @@ const { ceil, abs } = Math
8
8
 
9
9
  export function createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): boolean {
10
10
 
11
- let { scaleX, scaleY } = ui.__nowWorld
11
+ let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld
12
12
 
13
13
  const id = scaleX + '-' + scaleY
14
14