lottie-miniprogram
lottie-miniprogram copied to clipboard
当快速多次切换动画速度后,整个小程序就会卡死甚至崩溃了
@bigkrys 请提供个代码片段试试
` draw(animationData,assetsPath,animationSpeed,loop,autoplay){ wx.createSelectorQuery().select('#c1').node(res => { const canvas = res.node context = canvas.getContext('2d') let rate = 750/1334 canvas.width = (_that.data.width) * _that.data.pixelRatio canvas.height = (_that.data.width * rate ) * _that.data.pixelRatio canvas.top = 0 canvas.left = 0 context.scale(_that.data.pixelRatio, _that.data.pixelRatio) lottie.setup(canvas)//要执行动画,必须调用setup,传入canvas对象 _that.changeAnimationType(animationData,assetsPath,animationSpeed,loop,autoplay) }).exec() }, changeAnimationType(animationData,assetsPath,animationSpeed,loop,autoplay){ animation = lottie.loadAnimation({ loop: loop,//是否循环播放(选填) autoplay: autoplay,//是否自动播放(选填) animationData:animationData, rendererSettings:{ context:context, }, assetsPath:assetsPath, }) animation.setSpeed(animationSpeed) }, changeAnimation(animationType,animationSpeed){ console.info('_that.data.animationType',_that.data.animationType) _that.setData({ animationType:animationType }) let animationData = null,assetsPath = '',loop = true,autoplay = true if(animationType == 0){ //跑步 animationData = require("../../animation/running/running.js") }else if(animationType == 5){ //走路 animationData = require("../../animation/walking/walking.js") } if(animation && animation.animationID){ _that.changeAnimationType(animationData,assetsPath,animationSpeed,loop,autoplay) }else{ _that.draw(animationData,assetsPath,animationSpeed,loop,autoplay)
}
}, ` 当调用loadAnimation超过2次的时候,整个页面就会卡死,在安卓手机下甚至会崩溃
@bigkrys 有没有完整的代码片段 https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
@bigkrys 请问小程序奔溃的问题有解决方案么?
每次重新setup一下