Commit e970884b3c7c8e1b5a1e712d1437070e68da70c4

Authored by huanghong
1 parent 7f2e78d8

mousewheel support firefox and safari

Showing 1 changed file with 19 additions and 4 deletions   Show diff stats
src/components/table/table.vue
... ... @@ -12,7 +12,7 @@
12 12 :data="rebuildData"></table-head>
13 13 </div>
14 14 <div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll"
15   - @mousewheel="handleFixedMousewheel"
  15 + @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel"
16 16 v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
17 17 <table-body
18 18 ref="tbody"
... ... @@ -49,7 +49,8 @@
49 49 :data="rebuildData"></table-head>
50 50 </div>
51 51 <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody"
52   - @mousewheel="handleFixedMousewheel">
  52 + @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel"
  53 + @touchmove="handleFixedTouchmove">
53 54 <table-body
54 55 fixed="left"
55 56 :prefix-cls="prefixCls"
... ... @@ -72,7 +73,8 @@
72 73 :data="rebuildData"></table-head>
73 74 </div>
74 75 <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody"
75   - @mousewheel="handleFixedMousewheel">
  76 + @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel"
  77 + @touchmove="handleFixedTouchmove">
76 78 <table-body
77 79 fixed="right"
78 80 :prefix-cls="prefixCls"
... ... @@ -542,8 +544,21 @@
542 544 if (this.isRightFixed) this.$refs.fixedRightBody.scrollTop = event.target.scrollTop;
543 545 this.hideColumnFilter();
544 546 },
  547 + handleFixedTouchmove(event){
  548 + //console.log(event);
  549 + if(event.touches && event.touches.length && event.touches.length===1){
  550 + //const body = this.$refs.body;
  551 + }
  552 + },
545 553 handleFixedMousewheel(event) {
546   - const deltaY = event.deltaY;
  554 + let deltaY = event.deltaY;
  555 + if(!deltaY && event.detail){
  556 + deltaY = event.detail * 40;
  557 + }
  558 + if(!deltaY && event.wheelDeltaY){
  559 + deltaY = -event.wheelDeltaY;
  560 + }
  561 + if(!deltaY) return;
547 562 const body = this.$refs.body;
548 563 const currentScrollTop = body.scrollTop;
549 564 if (deltaY < 0 && currentScrollTop !== 0) {
... ...