在HarmonyOS NEXT开发中.scale没有动画效果?
.scale根本就没有动画效果:
@Component ImageScale {
@State scaleValue: ScaleOptions = { x: 1, y: 1, z: 1 }
build() {
Column() {
Image(this.viewModel?.item?.image?.hdUrl)
.width("100%")
.aspectRatio(1.0)
.animation({ duration: 200, curve: "ease" })
.scale(this.scaleValue)
.gesture(TapGesture({ count: 2 }).onAction((event: GestureEvent) => {
let width = event.target.area.width.valueOf() as number
let height = event.target.area.height.valueOf() as number
let centerX = event.fingerList[0].localX / width
let centerY = event.fingerList[0].localY / height
if (this.scaleMode) {
this.scaleMode = false
this.scaleValue = {x : 1, y : 1}
} else {
this.scaleMode = true
this.scaleValue = {x : 2, y : 2, centerX: `${centerX * 100}%`, centerY:`${centerY * 100}%`}
}
}))
}
}
}
参考此代码实现: