mirror of https://github.com/ElemeFE/element
Table: support header mousewheel scroll.
parent
cb5572f9d7
commit
496f385796
|
@ -96,6 +96,7 @@
|
||||||
import TableLayout from './table-layout';
|
import TableLayout from './table-layout';
|
||||||
import TableBody from './table-body';
|
import TableBody from './table-body';
|
||||||
import TableHeader from './table-header';
|
import TableHeader from './table-header';
|
||||||
|
import { mousewheel } from './util';
|
||||||
|
|
||||||
let tableIdSeed = 1;
|
let tableIdSeed = 1;
|
||||||
|
|
||||||
|
@ -185,6 +186,20 @@
|
||||||
if (refs.rightFixedBodyWrapper) refs.rightFixedBodyWrapper.scrollTop = this.scrollTop;
|
if (refs.rightFixedBodyWrapper) refs.rightFixedBodyWrapper.scrollTop = this.scrollTop;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mousewheel(headerWrapper, function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
mousewheel(headerWrapper, throttle(16, function(event) {
|
||||||
|
const deltaX = event.deltaX;
|
||||||
|
|
||||||
|
if (deltaX > 0) {
|
||||||
|
bodyWrapper.scrollLeft = bodyWrapper.scrollLeft + 10;
|
||||||
|
} else {
|
||||||
|
bodyWrapper.scrollLeft = bodyWrapper.scrollLeft - 10;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
if (this.fit) {
|
if (this.fit) {
|
||||||
this.windowResizeListener = throttle(50, () => {
|
this.windowResizeListener = throttle(50, () => {
|
||||||
if (this.$ready) this.doLayout();
|
if (this.$ready) this.doLayout();
|
||||||
|
|
|
@ -98,3 +98,11 @@ export const getColumnByCell = function(table, cell) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||||
|
|
||||||
|
export const mousewheel = function(element, callback) {
|
||||||
|
if (element && element.addEventListener) {
|
||||||
|
element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue