@leafer/image
Advanced tools
+7
-7
| { | ||
| "name": "@leafer/image", | ||
| "version": "1.12.2", | ||
| "version": "1.12.3", | ||
| "description": "@leafer/image", | ||
@@ -25,11 +25,11 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/task": "1.12.2", | ||
| "@leafer/file": "1.12.2", | ||
| "@leafer/data": "1.12.2", | ||
| "@leafer/math": "1.12.2", | ||
| "@leafer/platform": "1.12.2" | ||
| "@leafer/task": "1.12.3", | ||
| "@leafer/file": "1.12.3", | ||
| "@leafer/data": "1.12.3", | ||
| "@leafer/math": "1.12.3", | ||
| "@leafer/platform": "1.12.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.12.2" | ||
| "@leafer/interface": "1.12.3" | ||
| } | ||
| } |
+18
-7
@@ -1,2 +0,2 @@ | ||
| import { ILeaferImage, ILeaferImageConfig, IFunction, IObject, InnerId, IMatrixData, ICanvasPattern, ILeaferImageCacheCanvas, ILeaferImagePatternPaint } from '@leafer/interface' | ||
| import { ILeaferImage, ILeaferImageConfig, IFunction, IObject, InnerId, IMatrixData, ICanvasPattern, ILeaferImageCacheCanvas, ILeaferImagePatternPaint, ILeaferImageLevel, ISizeData, IImageCrossOrigin } from '@leafer/interface' | ||
| import { Platform } from '@leafer/platform' | ||
@@ -16,2 +16,3 @@ import { Resource } from '@leafer/file' | ||
| public get url() { return this.config.url } | ||
| public get crossOrigin(): IImageCrossOrigin { const { crossOrigin } = this.config; return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin } | ||
@@ -52,7 +53,9 @@ public view: any | ||
| public load(onSuccess?: IFunction, onError?: IFunction): number { | ||
| public load(onSuccess?: IFunction, onError?: IFunction, thumbSize?: ISizeData): number { | ||
| if (!this.loading) { | ||
| this.loading = true | ||
| const { crossOrigin } = this.config | ||
| Resource.tasker.add(async () => await Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch((e) => { | ||
| Resource.tasker.add(async () => await Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => { | ||
| if (thumbSize) this.setThumbView(img) | ||
| this.setView(img) | ||
| }).catch((e) => { | ||
| this.error = e | ||
@@ -77,5 +80,7 @@ this.onComplete(false) | ||
| this.ready = true | ||
| this.width = img.naturalWidth || img.width | ||
| this.height = img.naturalHeight || img.height | ||
| this.view = img | ||
| if (!this.width) { | ||
| this.width = img.width | ||
| this.height = img.height | ||
| this.view = img | ||
| } | ||
| this.onComplete(true) | ||
@@ -128,2 +133,8 @@ } | ||
| // need rewrite | ||
| public getLoadUrl(_thumbSize?: ISizeData): string { return this.url } | ||
| public setThumbView(_view: number): void { } | ||
| public getThumbSize(): ISizeData { return undefined } | ||
| public getMinLevel(): number { return undefined } | ||
| public getLevelData(_level: number): ILeaferImageLevel { return undefined } | ||
| public clearLevels(_checkUse?: boolean): void { } | ||
@@ -130,0 +141,0 @@ |
+8
-2
@@ -1,2 +0,2 @@ | ||
| import { ILeaferImage, InnerId, IObject, ILeaferImageConfig, IFunction, ILeaferImageCacheCanvas, IMatrixData, ILeaferImagePatternPaint, ICanvasPattern, IImageManager } from '@leafer/interface'; | ||
| import { ILeaferImage, InnerId, IImageCrossOrigin, IObject, ILeaferImageConfig, IFunction, ILeaferImageCacheCanvas, ISizeData, IMatrixData, ILeaferImagePatternPaint, ICanvasPattern, ILeaferImageLevel, IImageManager } from '@leafer/interface'; | ||
@@ -6,2 +6,3 @@ declare class LeaferImage implements ILeaferImage { | ||
| get url(): string; | ||
| get crossOrigin(): IImageCrossOrigin; | ||
| view: any; | ||
@@ -21,3 +22,3 @@ width: number; | ||
| constructor(config: ILeaferImageConfig); | ||
| load(onSuccess?: IFunction, onError?: IFunction): number; | ||
| load(onSuccess?: IFunction, onError?: IFunction, thumbSize?: ISizeData): number; | ||
| unload(index: number, stopEvent?: boolean): void; | ||
@@ -29,2 +30,7 @@ protected setView(img: any): void; | ||
| getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern; | ||
| getLoadUrl(_thumbSize?: ISizeData): string; | ||
| setThumbView(_view: number): void; | ||
| getThumbSize(): ISizeData; | ||
| getMinLevel(): number; | ||
| getLevelData(_level: number): ILeaferImageLevel; | ||
| clearLevels(_checkUse?: boolean): void; | ||
@@ -31,0 +37,0 @@ destroy(): void; |
10897
8.75%210
8.25%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated