@leafer-ui/image 1.0.1 → 1.0.2

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.1",
3
+ "version": "1.0.2",
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.1",
26
- "@leafer-ui/draw": "1.0.1"
25
+ "@leafer/core": "1.0.2",
26
+ "@leafer-ui/draw": "1.0.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.1",
30
- "@leafer-ui/interface": "1.0.1"
29
+ "@leafer/interface": "1.0.2",
30
+ "@leafer-ui/interface": "1.0.2"
31
31
  }
32
32
  }
package/src/check.ts CHANGED
@@ -43,7 +43,7 @@ export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, al
43
43
  canvas.restore()
44
44
  return true
45
45
  } else {
46
- if (!paint.style || Export.running) {
46
+ if (!paint.style || paint.sync || Export.running) {
47
47
  createPattern(ui, paint, canvas.pixelRatio)
48
48
  } else {
49
49
  if (!paint.patternTask) {
package/src/data.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { IBoundsData, ILeaferImage, IPointData } from '@leafer/interface'
2
- import { MatrixHelper, Bounds, AlignHelper } from '@leafer/core'
1
+ import { IBoundsData, ILeaferImage, IPointData, IScaleData } from '@leafer/interface'
2
+ import { MatrixHelper, MathHelper, Bounds, AlignHelper } from '@leafer/core'
3
3
 
4
4
  import { IImagePaint, ILeafPaint, ILeafPaintPatternData } from '@leafer-ui/interface'
5
5
 
@@ -9,10 +9,12 @@ import { clipMode, fillOrFitMode, repeatMode } from './mode'
9
9
  const { get, translate } = MatrixHelper
10
10
  const tempBox = new Bounds()
11
11
  const tempPoint = {} as IPointData
12
+ const tempScaleData = {} as IScaleData
12
13
 
13
14
  export function createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void {
14
- const { blendMode } = paint
15
+ const { blendMode, sync } = paint
15
16
  if (blendMode) leafPaint.blendMode = blendMode
17
+ if (sync) leafPaint.sync = sync
16
18
  leafPaint.data = getPatternData(paint, box, image)
17
19
  }
18
20
 
@@ -35,12 +37,10 @@ export function getPatternData(paint: IImagePaint, box: IBoundsData, image: ILea
35
37
  scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh)
36
38
  x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2
37
39
  }
38
- } else if (size) {
39
- scaleX = (typeof size === 'number' ? size : size.width) / width
40
- scaleY = (typeof size === 'number' ? size : size.height) / height
41
- } else if (scale) {
42
- scaleX = typeof scale === 'number' ? scale : scale.x
43
- scaleY = typeof scale === 'number' ? scale : scale.y
40
+ } else if (scale || size) {
41
+ MathHelper.getScaleData(scale, size, image, tempScaleData)
42
+ scaleX = tempScaleData.scaleX
43
+ scaleY = tempScaleData.scaleY
44
44
  }
45
45
 
46
46
  if (align) {