问题描述
js根据滚动条设置dom的left值会一卡一卡的,这种怎么优化?
问题出现的环境背景及自己尝试过哪些方法
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
let dom = this.$refs.scrollBox;
if (dom.scrollTop == this.scrollBox.scrollTop) {
if (dom.scrollLeft <= 0) {
document.getElementById("fixed-table").style.left = "0";
} else {
console.log(dom.scrollLeft);
// if (this.scrollTimer != "") {
// clearTimeout(this.scrollTimer);
// }
// this.scrollTimer = setTimeout(() => {
// $("#fixed-table").animate({ left:dom.scrollLeft + "px" });
// }, 10);
}
} else {
this.scrollBox.scrollTop = dom.scrollTop;
}
css
transition: left 1s linear