1.add onClick option,because ImageKnifeComponet used onClick Event let external layout failed to capture events

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2022-12-01 00:48:13 -08:00
parent fac8d53d33
commit 395b6f983e
2 changed files with 12 additions and 3 deletions

View File

@ -26,9 +26,10 @@ export struct ImageKnifeComponent {
@Watch('watchImageKnifeOption') @Link imageKnifeOption: ImageKnifeOption;
@State componentWidth: string = '100%'
@State componentHeight: string = '100%'
@State gifPixelMap: PixelMap = undefined;
drawLifeCycle: IDrawLifeCycle
autoPlay = true
@State gifAutoPlay?:boolean = true;
autoPlay:boolean = true
// 有效onAreaChanged触发计数
private onAreaCount: number = 0
private preSize: {
@ -101,8 +102,13 @@ export struct ImageKnifeComponent {
.backgroundColor(this.imageKnifeOption.backgroundColor ? this.imageKnifeOption.backgroundColor : Color.White)
.margin(this.imageKnifeOption.margin ? this.imageKnifeOption.margin : { left: 0, top: 0, right: 0, bottom: 0 })
.onReady(() => {
})
.onClick(() => {
.onClick((event:ClickEvent) => {
// 需要将点击事件回传
if(this.imageKnifeOption.onClick){
this.imageKnifeOption.onClick(event)
}
if (this.imageKnifeOption.canRetryClick && this.hasDisplayRetryholder) {
this.retryClick()
}

View File

@ -76,6 +76,9 @@ export class ImageKnifeOption {
// 用户自定义实现 绘制方案
drawLifeCycle?: IDrawLifeCycle;
// 设置点击事件回调
onClick?:(event?: ClickEvent) => void
gif?: {
loopFinish?: (loopTime?) => void
speedFactory?: number