liyubing

feat:1)修改lottieView

... ... @@ -186,8 +186,8 @@ export struct CardParser {
contentDTO: contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
pageName: this.pageName,
index:this.compIndex
})
} else {
// todo:组件未实现 / Component Not Implemented
... ...
... ... @@ -19,7 +19,7 @@ export struct LiveBigImage02Component {
@State contentDTO: ContentDTO = new ContentDTO();
@State loadImg: boolean = false;
@State clicked: boolean = false;
index: number = 0
async aboutToAppear() {
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId,curRouter)
... ... @@ -102,8 +102,7 @@ export struct LiveBigImage02Component {
lottieWidth: 14,
lottieHeight: 14,
autoplay: true,
loop: true,
title: item.newsTitle
loop: true
})
.margin({
right: '2vp'
... ...
... ... @@ -14,28 +14,16 @@ export struct LottieView {
private politeChickyController: CanvasRenderingContext2D =
new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象
private animateItem: AnimationItem | null = null; // 初始化loadAnimation接口的返回对象
@Prop title: string
// 页面隐藏销毁动画
// onPageHide(): void {
// this.animateItem?.destroy()
//
// if (this.onComplete) {
// this.animateItem?.removeEventListener('complete', this.onComplete)
// }
// }
/**
* 加载动画
* @param autoplay 控制动画是否自动播放参数
*/
loadAnimation() {
// 销毁动画,减少缓存
if (this.animateItem !== null) {
this.animateItem.destroy(this.name);
this.animateItem = null;
}
this.onDestroyAnimation()
this.animateItem = lottie.loadAnimation({
container: this.politeChickyController,
renderer: 'canvas',
... ... @@ -55,31 +43,18 @@ export struct LottieView {
}
aboutToAppear(): void {
// console.error('XXXXZZZZ', '-------aboutToAppear-------' + this.title)
//lottie?.play()
// if(this.init){
// if(this.animateItem = null){
// this.loadAnimation();
// }
// }
/**
* 摧毁动画
*/
onDestroyAnimation(){
// 销毁动画,减少缓存
if (this.animateItem !== null) {
this.animateItem.destroy(this.name);
this.animateItem = null;
}
}
aboutToDisappear(): void {
// console.error('XXXXZZZZ', '-------aboutToDisappear-------' + this.title)
// if(this.init){
// lottie?.destroy(this.name)
//
// if (this.onComplete) {
// this.animateItem?.removeEventListener('complete', this.onComplete)
// }
// this.animateItem = null;
// // }
}
build() {
Stack({ alignContent: Alignment.TopStart }) {
... ... @@ -92,10 +67,10 @@ export struct LottieView {
this.onReady(this.animateItem)
}
})
.onDisAppear(() => {
lottie.destroy(this.name)
this.animateItem = null;
}).onAppear(()=>{
.onDisAppear(()=>{
this.onDestroyAnimation()
})
.onAppear(()=>{
this.loadAnimation();
})
... ...
... ... @@ -41,6 +41,7 @@ export default struct TemplatePageComponent {
extra: string = ''
async aboutToAppear() {
Logger.debug(TAG, 'aboutToAppear')
this.requestPageData()
... ... @@ -78,9 +79,6 @@ export default struct TemplatePageComponent {
})
}
aboutToDisappear(): void {
}
build() {
if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) {
... ...