diff --git a/src/table.vue b/src/table.vue index 9a9f3db..abd29e0 100644 --- a/src/table.vue +++ b/src/table.vue @@ -3,7 +3,7 @@
@@ -133,9 +133,6 @@
0) { + const bodyWrapper = this.$refs.tableBody.$el; + const tableLayout = this.$refs.flexTableLayout; + const currentScrollLeft = this.scrollLeft; + const noYetScrollToLeft = normalized.pixelX < 0 && currentScrollLeft > 0; + const noYetScrollToRight = normalized.pixelX > 0 && bodyWrapper.clientWidth - tableLayout.clientWidth > currentScrollLeft; + if (noYetScrollToLeft || noYetScrollToRight) { + event.preventDefault(); + this.scrollLeft += Math.ceil(normalized.pixelX); + this.scrollLeft = Math.max(this.scrollLeft, 0); + this.$emit('on-scroll-x', event); + } + } }, doLayout: debounce(function() { this.resize(); @@ -628,27 +649,6 @@ export default { this.emitColResize.column = this.columns[index]; } }, - onTableScrollX(event) { - this.bodyIsScroll = event.target.scrollLeft; - if (!this.isInFixedHead){ - if (this.$refs.flexTableFixedHead) { - this.$refs.flexTableFixedHead.scrollLeft = event.target.scrollLeft; - } - this.$emit('on-scroll-x', event); - } - }, - onFixedHeadScrollX(event) { - if (this.isInFixedHead) { - this.$refs.flexTableLayout.scrollLeft = event.target.scrollLeft; - this.$emit('on-scroll-x', event); - } - }, - onFixedHeadOver(){ - this.isInFixedHead = true; - }, - sonFixedHeadLeave(){ - this.isInFixedHead = false; - }, handleScrollYScroll(e) { if(!this.scrollYScrolling) { return; } const scrollTop = e.target.scrollTop;