自动判断区域距离下边的距离和滚动:
curRecord.offsetTop是内部子元素的位置,curWrap.scrollTop是整个父级框子的可见高度
timer是模拟上滑动画的效果
changeConditionItem(index, data = {}) {
// 20220325 susie update start
let curRecord = document.getElementById('su-condition' + index);
let curWrap = document.getElementById('su-wrap');
// 若距离底部wrap小于3行的距离,则向上滑3行,100=每行21*3+缝隙
if ((curWrap.offsetHeight) - (curRecord.offsetTop - 21 - curWrap.scrollTop) < 100) {
let totalScroll = 0;
// 自动上滑时的动画效果
var timer = setInterval(function() {
if (totalScroll > 60) {
clearInterval(timer);
} else {
curWrap.scrollTop += 1;
totalScroll += 1;
}
}, 1);
}
// 20220325 susie update end
this.selectedConditionIndex = index;
this.viewImageAction(data);
},