@leafer/image 1.0.0-beta.10 → 1.0.0-beta.11
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 +4 -4
- package/src/ImageManager.ts +2 -2
- package/src/LeaferImageBase.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/image",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "@leafer/image",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/task": "1.0.0-beta.
|
|
23
|
-
"@leafer/platform": "1.0.0-beta.
|
|
22
|
+
"@leafer/task": "1.0.0-beta.11",
|
|
23
|
+
"@leafer/platform": "1.0.0-beta.11"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@leafer/interface": "1.0.0-beta.
|
|
26
|
+
"@leafer/interface": "1.0.0-beta.11"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/ImageManager.ts
CHANGED
|
@@ -26,14 +26,14 @@ export const ImageManager: IImageManager = {
|
|
|
26
26
|
|
|
27
27
|
recycle(image: ILeaferImage): void {
|
|
28
28
|
image.use--
|
|
29
|
-
setTimeout(() => { if (!image.use) I.recycledList.push(image) }
|
|
29
|
+
setTimeout(() => { if (!image.use) I.recycledList.push(image) })
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
clearRecycled(): void {
|
|
33
33
|
const list = I.recycledList
|
|
34
34
|
if (list.length) {
|
|
35
35
|
list.forEach(image => {
|
|
36
|
-
if (!image.use) {
|
|
36
|
+
if (!image.use && image.url) {
|
|
37
37
|
delete I.map[image.url]
|
|
38
38
|
image.destroy()
|
|
39
39
|
}
|
package/src/LeaferImageBase.ts
CHANGED
|
@@ -9,7 +9,7 @@ const { IMAGE, create } = IncrementId
|
|
|
9
9
|
export class LeaferImageBase implements ILeaferImage {
|
|
10
10
|
|
|
11
11
|
public readonly innerId: InnerId
|
|
12
|
-
public get url() { return this.config.url }
|
|
12
|
+
public get url() { return this.config && this.config.url }
|
|
13
13
|
|
|
14
14
|
public view: any
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ export class LeaferImageBase implements ILeaferImage {
|
|
|
44
44
|
public load(onSuccess: IFunction, onError: IFunction): number {
|
|
45
45
|
if (!this.loading) {
|
|
46
46
|
this.loading = true
|
|
47
|
-
ImageManager.tasker.
|
|
47
|
+
ImageManager.tasker.add(async () => await Platform.origin.loadImage(this.config.url).then((img) => {
|
|
48
48
|
this.ready = true
|
|
49
49
|
this.width = img.naturalWidth || img.width
|
|
50
50
|
this.height = img.naturalHeight || img.height
|
|
@@ -53,7 +53,7 @@ export class LeaferImageBase implements ILeaferImage {
|
|
|
53
53
|
}).catch((e) => {
|
|
54
54
|
this.error = e
|
|
55
55
|
this.onComplete(false)
|
|
56
|
-
})
|
|
56
|
+
}))
|
|
57
57
|
}
|
|
58
58
|
this.waitComplete.push(onSuccess, onError)
|
|
59
59
|
return this.waitComplete.length - 2
|