From 37a869de54094d7398988f3beb8947e9546b89a3 Mon Sep 17 00:00:00 2001 From: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:02:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(table):=20=E4=BD=BF=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=88=97=E7=9A=84=E6=BB=9A=E5=8A=A8=E6=9B=B4=E5=B9=B3=E6=BB=91?= =?UTF-8?q?=20(#2335)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index c8f15497..1ce63ac2 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2800,16 +2800,26 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ 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) { var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail; var scrollTop = that.layMain.scrollTop(); - var step = 30; + var step = 100; + var rAFStep = 10; 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); }); - } /**