admin管理员组文章数量:1580470
我就是想要做一个搜索栏随着下滑渐隐,随着上滑渐出的动画,但是找不到流畅的解决方案
一开始尝试用transition属性,判断下滑方向和搜索栏显示状态,当两者不一致时更新搜索栏height值。
在电脑上看着效果很好,但是用安卓测试的时候卡顿严重:
var now = e.detail.scrollTop
var last = this.data.scrollTop
var scrollDown = this.data.scrollDown
var sHeight = this.data.sHeight
if ((now > last && !scrollDown) || (now < last && scrollDown)) {
sHeight = 40-sHeight
this.data.scrollDown = !scrollDown
this.setData({
sHeight: sHeight
})
}
this.data.scrollTop = e.detail.scrollTop
然后尝试使用微信的animation API,然而卡顿依然严重:
var animation = wx.createAnimation({
duration: 500,
timingFunction: "ease"
})
this.animation = animation
if ((now > last && !scrollDown) || (now < last && scrollDown)) {
this.data.scrollDown = 1 - scrollDown
this.animation.scale(scrollDown).step()
this.setData({
sHeightAnim: this.animation.export()
})
}
this.data.scrollTop = e.detail.scrollTop
查了一下感觉transform和animation的运行效率也差不多,毕竟也是要走transition
所以有没有大佬可以提供一个较好的解决方案orz跪谢
版权声明:本文标题:android 过渡动画卡顿,请教如何优化一个简单但导致卡顿的过渡动画 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1727872357a1134887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论