Decrease table scroll speed

This commit is contained in:
huanghong 2018-03-21 21:47:11 +08:00
parent e25070eb84
commit 7f2e78d8db

View file

@ -12,6 +12,7 @@
:data="rebuildData"></table-head> :data="rebuildData"></table-head>
</div> </div>
<div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll" <div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll"
@mousewheel="handleFixedMousewheel"
v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))"> v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
<table-body <table-body
ref="tbody" ref="tbody"
@ -48,7 +49,7 @@
:data="rebuildData"></table-head> :data="rebuildData"></table-head>
</div> </div>
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody" <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody"
@wheel="handleFixedMousewheel"> @mousewheel="handleFixedMousewheel">
<table-body <table-body
fixed="left" fixed="left"
:prefix-cls="prefixCls" :prefix-cls="prefixCls"
@ -71,7 +72,7 @@
:data="rebuildData"></table-head> :data="rebuildData"></table-head>
</div> </div>
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody" <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody"
@wheel="handleFixedMousewheel"> @mousewheel="handleFixedMousewheel">
<table-body <table-body
fixed="right" fixed="right"
:prefix-cls="prefixCls" :prefix-cls="prefixCls"
@ -554,17 +555,17 @@
//body.scrollTop += deltaY; //body.scrollTop += deltaY;
let step = 0; let step = 0;
let timeId = setInterval(()=>{ let timeId = setInterval(()=>{
step+=10; step += 5;
if(deltaY>0){ if(deltaY>0){
body.scrollTop += 10; body.scrollTop += 2;
} }
else{ else{
body.scrollTop += -10; body.scrollTop -= 2;
} }
if(step>=Math.abs(deltaY)){ if(step >= Math.abs(deltaY)){
clearInterval(timeId); clearInterval(timeId);
} }
} , 20); }, 5);
}, },
handleMouseWheel (event) { handleMouseWheel (event) {
const deltaX = event.deltaX; const deltaX = event.deltaX;