@leafer-ui/data 1.0.0-beta.10 → 1.0.0-beta.12

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/UIData.ts +5 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/data",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "@leafer-ui/data",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,10 +19,10 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/core": "1.0.0-beta.10"
22
+ "@leafer/core": "1.0.0-beta.12"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.10",
26
- "@leafer-ui/interface": "1.0.0-beta.10"
25
+ "@leafer/interface": "1.0.0-beta.12",
26
+ "@leafer-ui/interface": "1.0.0-beta.12"
27
27
  }
28
28
  }
package/src/UIData.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { IBooleanMap, ILeaferImage, __Value } from '@leafer/interface'
2
- import { ImageManager, LeafData } from '@leafer/core'
1
+ import { __Value } from '@leafer/interface'
2
+ import { LeafData } from '@leafer/core'
3
3
 
4
4
  import { IShadowEffect, IUI, IUIData, IUnitData, ILeafPaint } from '@leafer-ui/interface'
5
+ import { Paint } from '@leafer-ui/external'
5
6
 
6
7
 
7
8
  const emptyPaint: ILeafPaint = {}
@@ -26,7 +27,7 @@ export class UIData extends LeafData implements IUIData {
26
27
  if (typeof value === 'string' || !value) {
27
28
  if (this.__isFills) {
28
29
  this.__removeInput('fill')
29
- this.__recycleImage('fill')
30
+ Paint.recycleImage(this, 'fill')
30
31
  this.__isFills = false
31
32
  }
32
33
  this._fill = value
@@ -42,7 +43,7 @@ export class UIData extends LeafData implements IUIData {
42
43
  if (typeof value === 'string' || !value) {
43
44
  if (this.__isStrokes) {
44
45
  this.__removeInput('stroke')
45
- this.__recycleImage('stroke')
46
+ Paint.recycleImage(this, 'stroke')
46
47
  this.__isStrokes = false
47
48
  }
48
49
  this._stroke = value
@@ -78,31 +79,6 @@ export class UIData extends LeafData implements IUIData {
78
79
  }
79
80
  }
80
81
 
81
- public __recycleImage(attrName: string): IBooleanMap {
82
- const paints = (attrName === 'fill' ? this._fill : this._stroke) as ILeafPaint[]
83
- if (paints instanceof Array) {
84
- let image: ILeaferImage, map: IBooleanMap
85
- for (let i = 0, len = paints.length; i < len; i++) {
86
- image = paints[i].image
87
- if (image) {
88
- const { url } = image
89
- if (!map) map = {}
90
- map[url] = true
91
- ImageManager.recycle(image)
92
-
93
- // stop load
94
- if (image.loading) {
95
- const p = this.__input && this.__input[attrName]
96
- const hasSame = p && (p instanceof Array ? p.some(item => item.url === url) : p.url === url)
97
- if (!hasSame) image.unload(paints[i].loadId)
98
- }
99
- }
100
- }
101
- return map
102
- }
103
- return null
104
- }
105
-
106
82
  }
107
83
 
108
84