轮播循环切换闪动原因及解决
轮播图最后一页切换回第一页时出现闪动,原因如下:
当使用 translate3d 方式切换时,CSS 样式没有及时更新。解决这个问题的方法是修改 changeCur 方法:
changeCur(add) {
this.con.style.transitionDuration = '.3s';
let cur = parseInt(this.out.style.getPropertyValue('--cur'));
if (add) {
if (cur === this.num) {
this.con.style.transitionDuration = '0s';
this.setCur(0);
this.con.offsetWidth;
this.con.style.transitionDuration = '.3s';
this.setCur(1);
} else {
this.setCur(cur + 1);
}
} else {
if (cur === 1) {
this.con.style.transitionDuration = '0s';
this.setCur(this.num + 1);
this.con.offsetWidth;
this.con.style.transitionDuration = '.3s';
this.setCur(this.num);
} else {
this.setCur(cur - 1);
}
}
}
以上就是轮播图最后一页切换回第一页时出现闪动,如何解决?的详细内容,更多请关注知识资源分享宝库其它相关文章!
版权声明
本站内容来源于互联网搬运,
仅限用于小范围内传播学习,请在下载后24小时内删除,
如果有侵权内容、不妥之处,请第一时间联系我们删除。敬请谅解!
E-mail:dpw1001@163.com
发表评论