首页 > 需要在手机页面上元素跟随手指,用了touchmove,但所有手机都有点卡顿的感觉?

需要在手机页面上元素跟随手指,用了touchmove,但所有手机都有点卡顿的感觉?

就是监听了touchmove的位置让元素移动,但有些卡顿,要很慢滑动才会有效果?


1、用transform:translateY移动,避免直接操作top、margin-top等导致页面频繁reflow
2、touchmove的handler里面,需要执行preventDefault(),屏蔽掉原生滚动


你的需求我做過類似的,自己實現 elastic scrolling,用的 touchmove 和 transform3d。

毫無違和感。

https://bumfo.github.io/overflow.html


用transform3d更好可以开启硬件加速

【热门文章】
【热门文章】