ImageKnife/entry/src/main/ets/pages/ImageAnimatorPage.ets

41 lines
1.3 KiB
Plaintext

import { AnimatorOption, ImageKnifeAnimatorComponent } from "@ohos/libraryimageknife"
@Entry
@Component
struct ImageAnimatorPage {
@State animatorOption: AnimatorOption = {
state: AnimationStatus.Running,
iterations: -1
}
build() {
Column(){
Flex(){
Button("播放").onClick(()=>{
this.animatorOption.state = AnimationStatus.Running
})
Button("暂停").onClick(()=>{
this.animatorOption.state = AnimationStatus.Paused
})
Button("停止").onClick(()=>{
this.animatorOption.state = AnimationStatus.Stopped
})
Button("无限循环").onClick(()=>{
this.animatorOption.iterations = -1
})
Button("播放一次").onClick(()=>{
this.animatorOption.iterations = 1
})
Button("播放两次").onClick(()=>{
this.animatorOption.iterations = 2
})
}
ImageKnifeAnimatorComponent({
imageKnifeOption:{
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed')
},animatorOption:this.animatorOption
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
}.width("100%").height("100%")
}
}