mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-16 11:44:01 +08:00
Table: support header mousewheel scroll.
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
import TableLayout from './table-layout';
|
||||
import TableBody from './table-body';
|
||||
import TableHeader from './table-header';
|
||||
import { mousewheel } from './util';
|
||||
|
||||
let tableIdSeed = 1;
|
||||
|
||||
@@ -185,6 +186,20 @@
|
||||
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) {
|
||||
this.windowResizeListener = throttle(50, () => {
|
||||
if (this.$ready) this.doLayout();
|
||||
|
||||
@@ -98,3 +98,11 @@ export const getColumnByCell = function(table, cell) {
|
||||
}
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user