swiper组件快速滑动会抖动是怎么会是?

发布于 9 年前作者 jie693516 次浏览最后编辑 9 年前来自 issues

swiper组件快速滑动的时候会疯狂抖动像鬼畜一样而且根本停不下来,请问有什么解决方案吗?

3 回复
fanfang
fanfang1 楼6 年前

如果去掉JS代码也同样情况,再来问这个问题。

huangxiulan
huangxiulan2 楼6 年前

如果你确实需要修改current的值,又担心swiper的抖动,建议你将修改current值的代码,放入setTimeout中异步触发,并且每次都clearTimeout,这样不管你滑动的多快,只执行一次赋值行为。解决赋值导致的自动滚动和你手动快速滑动引起的冲突导致的抖动bug。

类似于:

if (swiperCurrentTimeout) clearTimeout(swiperCurrentTimeout);
swiperCurrentTimeout = setTimeout(() => {this.current = current;});
tangming
tangming3 楼6 年前

不要手动滑动了还去设current

仔细阅读文档的 bug & tip

https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html