feat(table): 使固定列的滚动更平滑 (#2335)

pull/2340/head
morning-star 6 days ago committed by GitHub
parent b6eb3ba2a5
commit 37a869de54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2800,16 +2800,26 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
layer.close(that.tipsIndex); layer.close(that.tipsIndex);
}); });
var rAF = window.requestAnimationFrame || function(fn){return setTimeout(fn, 1000 / 60)};
// 固定列滚轮事件 - 临时兼容方案 // 固定列滚轮事件 - 临时兼容方案
that.layFixed.find(ELEM_BODY).on('mousewheel DOMMouseScroll', function(e) { that.layFixed.find(ELEM_BODY).on('mousewheel DOMMouseScroll', function(e) {
var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail; var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
var scrollTop = that.layMain.scrollTop(); var scrollTop = that.layMain.scrollTop();
var step = 30; var step = 100;
var rAFStep = 10;
e.preventDefault(); e.preventDefault();
that.layMain.scrollTop(scrollTop + (delta > 0 ? -step : step)); var cb = function(){
if(step > 0){
step -= rAFStep;
scrollTop += (delta > 0 ? -rAFStep : rAFStep);
that.layMain.scrollTop(scrollTop);
rAF(cb);
}
}
rAF(cb);
}); });
} }
/** /**

Loading…
Cancel
Save