@leafer-ui/image 2.1.5 → 2.1.7

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": "2.1.5",
3
+ "version": "2.1.7",
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": "2.1.5",
26
- "@leafer-ui/draw": "2.1.5"
25
+ "@leafer/core": "2.1.7",
26
+ "@leafer-ui/draw": "2.1.7"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "2.1.5",
30
- "@leafer-ui/interface": "2.1.5"
29
+ "@leafer/interface": "2.1.7",
30
+ "@leafer-ui/interface": "2.1.7"
31
31
  }
32
32
  }
package/src/data.ts CHANGED
@@ -66,8 +66,8 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
66
66
  }
67
67
  break
68
68
  case 'repeat':
69
- case 'brush':
70
69
  if (!sameBox || scaleX || rotation || skew) PaintImage.repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform)
70
+ case 'brush':
71
71
  if (!repeat) data.repeat = 'repeat'
72
72
  const count = isObject(repeat)
73
73
  if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box)
@@ -78,7 +78,7 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
78
78
  if (scaleX) PaintImage.fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation)
79
79
  }
80
80
 
81
- if (!data.transform) {
81
+ if (!data.transform && mode !== 'brush') {
82
82
  if (box.x || box.y) translate(data.transform = get(), box.x, box.y)
83
83
  }
84
84
 
package/src/image.ts CHANGED
@@ -94,7 +94,8 @@ function checkSizeAndCreateData(ui: IUI, attrName: IPaintAttr, paint: IImagePain
94
94
  data.__naturalHeight = image.height / data.pixelRatio
95
95
  if (data.__autoSide) {
96
96
  ui.forceUpdate('width')
97
- LeafHelper.updateBounds(ui) // 立即更新 boxBounds
97
+ LeafHelper.updateBounds(ui) // 立即更新 boxBounds,避免图片闪动
98
+ ui.__layout.boundsChanged = true // fix(flow): 仍需要标记,以通知父级更新 bounds
98
99
  if (ui.__proxyData) {
99
100
  ui.setProxyAttr('width', data.width)
100
101
  ui.setProxyAttr('height', data.height)
@@ -103,7 +104,7 @@ function checkSizeAndCreateData(ui: IUI, attrName: IPaintAttr, paint: IImagePain
103
104
  }
104
105
  }
105
106
 
106
- if (paint.mode === 'brush') PaintImage.brush(leafPaint, ui, attrName)
107
+ if (paint.mode === 'brush') PaintImage.brush(ui, attrName, leafPaint)
107
108
 
108
109
  if (!leafPaint.data) {
109
110
  PaintImage.createData(leafPaint, image, paint, boxBounds)
package/src/pattern.ts CHANGED
@@ -26,9 +26,10 @@ export function createPattern(paint: ILeafPaint, ui: IUI, canvas: ILeaferCanvas,
26
26
  if (paint.patternId !== id && !ui.destroyed) {
27
27
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
28
28
 
29
- const { image, brush, data } = paint, { opacity } = paint.originPaint as IImagePaint, { transform, gap } = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY)
30
- let imageMatrix: IMatrixData, xGap: number, yGap: number, { width, height } = image
29
+ const { image, brush, data } = paint, { transform, gap } = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY)
30
+ let imageMatrix: IMatrixData, xGap: number, yGap: number, { width, height } = image, { opacity } = paint.originPaint as IImagePaint
31
31
 
32
+ if (brush || opacity === 1) opacity = undefined
32
33
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale
33
34
 
34
35
  width *= scaleX