@leafer-ui/image 2.0.2 → 2.0.4

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.0.2",
3
+ "version": "2.0.4",
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.0.2",
26
- "@leafer-ui/draw": "2.0.2"
25
+ "@leafer/core": "2.0.4",
26
+ "@leafer-ui/draw": "2.0.4"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "2.0.2",
30
- "@leafer-ui/interface": "2.0.2"
29
+ "@leafer/interface": "2.0.4",
30
+ "@leafer-ui/interface": "2.0.4"
31
31
  }
32
32
  }
package/src/check.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeaferCanvas, IRenderOptions, IScaleData } from '@leafer/interface'
2
- import { Platform, ResizeEvent } from '@leafer/core'
2
+ import { Platform } from '@leafer/core'
3
3
 
4
4
  import { IUI, ILeafPaint, IImagePaint } from '@leafer-ui/interface'
5
5
  import { PaintImage } from "@leafer-ui/draw"
@@ -16,7 +16,7 @@ export function checkImage(paint: ILeafPaint, drawImage: boolean, ui: IUI, canva
16
16
  if (drawImage) {
17
17
  if (data.repeat) {
18
18
  drawImage = false
19
- } else if (!((originPaint as IImagePaint).changeful || paint.film || (Platform.name === 'miniapp' && ResizeEvent.isResizing(ui)) || exporting)) { // 小程序resize过程中直接绘制原图(绕过垃圾回收bug)
19
+ } else if (!((originPaint as IImagePaint).changeful || paint.film || Platform.name === 'miniapp' || exporting)) { // 小程序直接绘制原图(绕过垃圾回收bug)
20
20
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096 // 非image类型的尽量绘制原图,大长图单边超过8096生成pattern会有问题
21
21
  }
22
22
  }
package/src/image.ts CHANGED
@@ -108,6 +108,9 @@ function checkSizeAndCreateData(ui: IUI, attrName: string, paint: IImagePaint, i
108
108
  const clip = (transform && !transform.onlyScale) || data.path || data.cornerRadius
109
109
  if (clip || (opacity && opacity < 1) || blendMode) leafPaint.complex = clip ? 2 : true
110
110
  }
111
+
112
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui)
113
+
111
114
  return true
112
115
  }
113
116
 
package/src/pattern.ts CHANGED
@@ -26,7 +26,7 @@ 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, data } = paint, { opacity, filters } = paint.originPaint as IImagePaint, { transform, gap } = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY)
29
+ const { image, data } = paint, { opacity } = paint.originPaint as IImagePaint, { transform, gap } = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY)
30
30
  let imageMatrix: IMatrixData, xGap: number, yGap: number, { width, height } = image
31
31
 
32
32
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale
@@ -49,7 +49,7 @@ export function createPattern(paint: ILeafPaint, ui: IUI, canvas: ILeaferCanvas,
49
49
  scale(imageMatrix, 1 / scaleX, 1 / scaleY)
50
50
  }
51
51
 
52
- const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace)
52
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace)
53
53
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint)
54
54
 
55
55
  paint.style = pattern
package/src/recycle.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { IBooleanMap, ILeaferImage, IObject } from '@leafer/interface'
2
2
  import { ImageManager, isArray } from '@leafer/core'
3
3
 
4
- import { IImagePaint, ILeafPaint, IPaintAttr, IUIData } from '@leafer-ui/interface'
4
+ import { IImagePaint, ILeafPaint, IPaintAttr, IUI, IUIData } from '@leafer-ui/interface'
5
+ import { PaintImage } from "@leafer-ui/draw"
5
6
 
6
7
 
7
8
  export function recycleImage(attrName: IPaintAttr, data: IUIData): IBooleanMap {
@@ -21,6 +22,7 @@ export function recycleImage(attrName: IPaintAttr, data: IUIData): IBooleanMap {
21
22
  if (!recycleMap) recycleMap = {}
22
23
  recycleMap[url] = true
23
24
  ImageManager.recyclePaint(paint)
25
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf as IUI)
24
26
 
25
27
  // stop load
26
28
  if (image.loading) {