@leafer/image 1.0.0-beta.11 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/image",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.12",
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.11",
23
- "@leafer/platform": "1.0.0-beta.11"
22
+ "@leafer/task": "1.0.0-beta.12",
23
+ "@leafer/platform": "1.0.0-beta.12"
24
24
  },
25
25
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-beta.11"
26
+ "@leafer/interface": "1.0.0-beta.12"
27
27
  }
28
28
  }
@@ -44,7 +44,6 @@ export const ImageManager: IImageManager = {
44
44
 
45
45
  destroy(): void {
46
46
  I.map = {}
47
- I.tasker = null
48
47
  }
49
48
 
50
49
  }
@@ -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 && this.config.url }
12
+ public get url() { return this.config.url }
13
13
 
14
14
  public view: any
15
15
 
@@ -32,7 +32,7 @@ export class LeaferImageBase implements ILeaferImage {
32
32
 
33
33
  constructor(config: ILeaferImageConfig) {
34
34
  this.innerId = create(IMAGE)
35
- this.config = config
35
+ this.config = config || { url: '' }
36
36
  const { url } = config
37
37
  if (url.startsWith('data:')) {
38
38
  if (url.startsWith('data:image/svg')) this.isSVG = true
@@ -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.add(async () => await Platform.origin.loadImage(this.config.url).then((img) => {
47
+ ImageManager.tasker.add(async () => await Platform.origin.loadImage(this.url).then((img) => {
48
48
  this.ready = true
49
49
  this.width = img.naturalWidth || img.width
50
50
  this.height = img.naturalHeight || img.height
@@ -59,10 +59,12 @@ export class LeaferImageBase implements ILeaferImage {
59
59
  return this.waitComplete.length - 2
60
60
  }
61
61
 
62
- public unload(index: number): void {
62
+ public unload(index: number, stopEvent?: boolean): void {
63
63
  const l = this.waitComplete
64
- const error = l[index + 1]
65
- if (error) error({ type: 'stop' })
64
+ if (stopEvent) {
65
+ const error = l[index + 1]
66
+ if (error) error({ type: 'stop' })
67
+ }
66
68
  l[index] = l[index + 1] = undefined
67
69
  }
68
70
 
@@ -93,8 +95,7 @@ export class LeaferImageBase implements ILeaferImage {
93
95
  }
94
96
 
95
97
  public destroy(): void {
96
- this.view = null
97
- this.config = null
98
+ this.config = { url: '' }
98
99
  this.waitComplete.length = 0
99
100
  }
100
101