Commit e970884b3c7c8e1b5a1e712d1437070e68da70c4
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,7 +12,7 @@ | ||
12 | :data="rebuildData"></table-head> | 12 | :data="rebuildData"></table-head> |
13 | </div> | 13 | </div> |
14 | <div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll" | 14 | <div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll" |
15 | - @mousewheel="handleFixedMousewheel" | 15 | + @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel" |
16 | v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))"> | 16 | v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))"> |
17 | <table-body | 17 | <table-body |
18 | ref="tbody" | 18 | ref="tbody" |
@@ -49,7 +49,8 @@ | @@ -49,7 +49,8 @@ | ||
49 | :data="rebuildData"></table-head> | 49 | :data="rebuildData"></table-head> |
50 | </div> | 50 | </div> |
51 | <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody" | 51 | <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody" |
52 | - @mousewheel="handleFixedMousewheel"> | 52 | + @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel" |
53 | + @touchmove="handleFixedTouchmove"> | ||
53 | <table-body | 54 | <table-body |
54 | fixed="left" | 55 | fixed="left" |
55 | :prefix-cls="prefixCls" | 56 | :prefix-cls="prefixCls" |
@@ -72,7 +73,8 @@ | @@ -72,7 +73,8 @@ | ||
72 | :data="rebuildData"></table-head> | 73 | :data="rebuildData"></table-head> |
73 | </div> | 74 | </div> |
74 | <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody" | 75 | <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody" |
75 | - @mousewheel="handleFixedMousewheel"> | 76 | + @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel" |
77 | + @touchmove="handleFixedTouchmove"> | ||
76 | <table-body | 78 | <table-body |
77 | fixed="right" | 79 | fixed="right" |
78 | :prefix-cls="prefixCls" | 80 | :prefix-cls="prefixCls" |
@@ -542,8 +544,21 @@ | @@ -542,8 +544,21 @@ | ||
542 | if (this.isRightFixed) this.$refs.fixedRightBody.scrollTop = event.target.scrollTop; | 544 | if (this.isRightFixed) this.$refs.fixedRightBody.scrollTop = event.target.scrollTop; |
543 | this.hideColumnFilter(); | 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 | handleFixedMousewheel(event) { | 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 | const body = this.$refs.body; | 562 | const body = this.$refs.body; |
548 | const currentScrollTop = body.scrollTop; | 563 | const currentScrollTop = body.scrollTop; |
549 | if (deltaY < 0 && currentScrollTop !== 0) { | 564 | if (deltaY < 0 && currentScrollTop !== 0) { |