mirror of
https://gitee.com/openharmony-tpc/ImageKnife.git
synced 2026-05-24 17:25:44 +08:00
Canvas的key改为唯一ID(UUID)
Signed-off-by: zenggaofeng <zenggaofeng2@h-partners.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
"main": "index.ets",
|
||||
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
||||
"type": "module",
|
||||
"version": "2.1.2-rc.7",
|
||||
"version": "2.1.2-rc.8",
|
||||
"dependencies": {
|
||||
"pako": "^2.1.0",
|
||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||
|
||||
@@ -26,7 +26,11 @@ import common from '@ohos.app.ability.common'
|
||||
import { ObjectKey } from './ObjectKey'
|
||||
import componentUtils from '@ohos.arkui.componentUtils'
|
||||
import inspector from '@ohos.arkui.inspector'
|
||||
import util from '@ohos.util'
|
||||
|
||||
interface KeyCanvas {
|
||||
keyId:string
|
||||
}
|
||||
@Component
|
||||
export struct ImageKnifeComponent {
|
||||
@Watch('watchImageKnifeOption') @ObjectLink imageKnifeOption: ImageKnifeOption;
|
||||
@@ -47,6 +51,9 @@ export struct ImageKnifeComponent {
|
||||
// 抗锯齿属性
|
||||
private imageSmoothingQuality: ImageSmoothingQuality = 'low';
|
||||
private imageSmoothingEnabled: boolean = true;
|
||||
@State keyCanvas: KeyCanvas = {
|
||||
keyId: util.generateRandomUUID()
|
||||
}
|
||||
defaultLifeCycle: IDrawLifeCycle = {
|
||||
|
||||
// 展示占位图
|
||||
@@ -94,12 +101,12 @@ export struct ImageKnifeComponent {
|
||||
private detachFromLayoutGIF :DetachFromLayout|undefined = undefined;
|
||||
|
||||
private detachFromLayoutPixelMap :DetachFromLayout|undefined = undefined;
|
||||
listener: inspector.ComponentObserver = inspector.createComponentObserver("ImageKnifeCanvas")
|
||||
private value: componentUtils.ComponentInfo = componentUtils.getRectangleById("ImageKnifeCanvas")
|
||||
listener: inspector.ComponentObserver = inspector.createComponentObserver(this.keyCanvas.keyId)
|
||||
private value: componentUtils.ComponentInfo = componentUtils.getRectangleById(this.keyCanvas.keyId)
|
||||
|
||||
build() {
|
||||
Canvas(this.context)
|
||||
.key("ImageKnifeCanvas")
|
||||
.key(this.keyCanvas.keyId)
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.renderFit(RenderFit.RESIZE_FILL)
|
||||
@@ -126,7 +133,7 @@ export struct ImageKnifeComponent {
|
||||
})
|
||||
}
|
||||
onLayoutComplete:()=>void = ():void=>{
|
||||
this.value = componentUtils.getRectangleById("ImageKnifeCanvas");
|
||||
this.value = componentUtils.getRectangleById(this.keyCanvas.keyId);
|
||||
this.currentWidth = px2vp(this.value.size.width)
|
||||
this.currentHeight = px2vp(this.value.size.height)
|
||||
if (this.currentWidth <= 0 || this.currentHeight <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user