Browse Source

表格加入横向滚动事件

es6
guy 8 years ago
parent
commit
f638558b07
  1. 139
      bi/base.js
  2. 139
      docs/base.js
  3. 71
      src/base/table/table.collection.quick.js
  4. 68
      src/base/table/table.grid.quick.js

139
bi/base.js

@ -29036,26 +29036,54 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, {
mounted: function () { mounted: function () {
BI.QuickCollectionTable.superclass.mounted.apply(this, arguments); BI.QuickCollectionTable.superclass.mounted.apply(this, arguments);
var self = this; var self = this;
this._leftWheelHandler = new BI.WheelHandler( this._topLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._rightWheelHandler = new BI.WheelHandler( this._topRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this._bottomLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._bottomRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this.topLeftCollection.element.mousewheel(function (e) {
self._topLeftWheelHandler.onWheel(e.originalEvent);
});
this.topRightCollection.element.mousewheel(function (e) {
self._topRightWheelHandler.onWheel(e.originalEvent);
});
this.bottomLeftCollection.element.mousewheel(function (e) { this.bottomLeftCollection.element.mousewheel(function (e) {
self._leftWheelHandler.onWheel(e.originalEvent); self._bottomLeftWheelHandler.onWheel(e.originalEvent);
}); });
this.bottomRightCollection.element.mousewheel(function (e) { this.bottomRightCollection.element.mousewheel(function (e) {
self._rightWheelHandler.onWheel(e.originalEvent); self._bottomRightWheelHandler.onWheel(e.originalEvent);
}); });
}, },
_shouldHandleX: function (delta) { _shouldHandleLeftX: function (delta) {
return false; if (delta > 0) {
return this.bottomLeftCollection.getScrollLeft() < this.bottomLeftCollection.getMaxScrollLeft();
} else {
return this.bottomLeftCollection.getScrollLeft() > 0;
}
},
_shouldHandleRightX: function (delta) {
if (delta > 0) {
return this.bottomRightCollection.getScrollLeft() < this.bottomRightCollection.getMaxScrollLeft();
} else {
return this.bottomRightCollection.getScrollLeft() > 0;
}
}, },
_shouldHandleY: function (delta) { _shouldHandleY: function (delta) {
@ -29066,19 +29094,38 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, {
} }
}, },
_onWheelY: function (deltaX, deltaY) { _onWheelLeft: function (deltaX, deltaY) {
var self = this;
var scrollTop = this.bottomLeftCollection.getScrollTop();
var scrollLeft = this.bottomLeftCollection.getScrollLeft();
scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop);
this.topLeftCollection.setScrollLeft(scrollLeft);
this.bottomLeftCollection.setScrollLeft(scrollLeft);
self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
},
_onWheelRight: function (deltaX, deltaY) {
var self = this; var self = this;
var scrollTop = this.bottomRightCollection.getScrollTop(); var scrollTop = this.bottomRightCollection.getScrollTop();
var scrollLeft = this.bottomRightCollection.getScrollLeft();
scrollTop += deltaY; scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftCollection.setScrollTop(scrollTop); this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop); this.bottomRightCollection.setScrollTop(scrollTop);
this.topRightCollection.setScrollLeft(scrollLeft);
this.bottomRightCollection.setScrollLeft(scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
}, },
_populateTable: function () { _populateTable: function () {
var self = this, o = this.options; var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -29691,26 +29738,54 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, {
mounted: function () { mounted: function () {
BI.QuickGridTable.superclass.mounted.apply(this, arguments); BI.QuickGridTable.superclass.mounted.apply(this, arguments);
var self = this; var self = this;
this._leftWheelHandler = new BI.WheelHandler( this._topLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._rightWheelHandler = new BI.WheelHandler( this._topRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this._bottomLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._bottomRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this.topLeftGrid.element.mousewheel(function (e) {
self._topLeftWheelHandler.onWheel(e.originalEvent);
});
this.topRightGrid.element.mousewheel(function (e) {
self._topRightWheelHandler.onWheel(e.originalEvent);
});
this.bottomLeftGrid.element.mousewheel(function (e) { this.bottomLeftGrid.element.mousewheel(function (e) {
self._leftWheelHandler.onWheel(e.originalEvent); self._bottomLeftWheelHandler.onWheel(e.originalEvent);
}); });
this.bottomRightGrid.element.mousewheel(function (e) { this.bottomRightGrid.element.mousewheel(function (e) {
self._rightWheelHandler.onWheel(e.originalEvent); self._bottomRightWheelHandler.onWheel(e.originalEvent);
}); });
}, },
_shouldHandleX: function (delta) { _shouldHandleLeftX: function (delta) {
return false; if (delta > 0) {
return this.bottomLeftGrid.getScrollLeft() < this.bottomLeftGrid.getMaxScrollLeft();
} else {
return this.bottomLeftGrid.getScrollLeft() > 0;
}
},
_shouldHandleRightX: function (delta) {
if (delta > 0) {
return this.bottomRightGrid.getScrollLeft() < this.bottomRightGrid.getMaxScrollLeft();
} else {
return this.bottomRightGrid.getScrollLeft() > 0;
}
}, },
_shouldHandleY: function (delta) { _shouldHandleY: function (delta) {
@ -29721,12 +29796,30 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, {
} }
}, },
_onWheelY: function (deltaX, deltaY) { _onWheelLeft: function (deltaX, deltaY) {
var self = this;
var scrollTop = this.bottomLeftGrid.getScrollTop();
var scrollLeft = this.bottomLeftGrid.getScrollLeft();
scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftGrid.setScrollTop(scrollTop);
this.bottomRightGrid.setScrollTop(scrollTop);
this.topLeftGrid.setScrollLeft(scrollLeft);
this.bottomLeftGrid.setScrollLeft(scrollLeft);
self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
},
_onWheelRight: function (deltaX, deltaY) {
var self = this; var self = this;
var scrollTop = this.bottomRightGrid.getScrollTop(); var scrollTop = this.bottomRightGrid.getScrollTop();
var scrollLeft = this.bottomRightGrid.getScrollLeft();
scrollTop += deltaY; scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftGrid.setScrollTop(scrollTop); this.bottomLeftGrid.setScrollTop(scrollTop);
this.bottomRightGrid.setScrollTop(scrollTop); this.bottomRightGrid.setScrollTop(scrollTop);
this.topRightGrid.setScrollLeft(scrollLeft);
this.bottomRightGrid.setScrollLeft(scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
}, },

139
docs/base.js

@ -29036,26 +29036,54 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, {
mounted: function () { mounted: function () {
BI.QuickCollectionTable.superclass.mounted.apply(this, arguments); BI.QuickCollectionTable.superclass.mounted.apply(this, arguments);
var self = this; var self = this;
this._leftWheelHandler = new BI.WheelHandler( this._topLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._rightWheelHandler = new BI.WheelHandler( this._topRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this._bottomLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._bottomRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this.topLeftCollection.element.mousewheel(function (e) {
self._topLeftWheelHandler.onWheel(e.originalEvent);
});
this.topRightCollection.element.mousewheel(function (e) {
self._topRightWheelHandler.onWheel(e.originalEvent);
});
this.bottomLeftCollection.element.mousewheel(function (e) { this.bottomLeftCollection.element.mousewheel(function (e) {
self._leftWheelHandler.onWheel(e.originalEvent); self._bottomLeftWheelHandler.onWheel(e.originalEvent);
}); });
this.bottomRightCollection.element.mousewheel(function (e) { this.bottomRightCollection.element.mousewheel(function (e) {
self._rightWheelHandler.onWheel(e.originalEvent); self._bottomRightWheelHandler.onWheel(e.originalEvent);
}); });
}, },
_shouldHandleX: function (delta) { _shouldHandleLeftX: function (delta) {
return false; if (delta > 0) {
return this.bottomLeftCollection.getScrollLeft() < this.bottomLeftCollection.getMaxScrollLeft();
} else {
return this.bottomLeftCollection.getScrollLeft() > 0;
}
},
_shouldHandleRightX: function (delta) {
if (delta > 0) {
return this.bottomRightCollection.getScrollLeft() < this.bottomRightCollection.getMaxScrollLeft();
} else {
return this.bottomRightCollection.getScrollLeft() > 0;
}
}, },
_shouldHandleY: function (delta) { _shouldHandleY: function (delta) {
@ -29066,19 +29094,38 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, {
} }
}, },
_onWheelY: function (deltaX, deltaY) { _onWheelLeft: function (deltaX, deltaY) {
var self = this;
var scrollTop = this.bottomLeftCollection.getScrollTop();
var scrollLeft = this.bottomLeftCollection.getScrollLeft();
scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop);
this.topLeftCollection.setScrollLeft(scrollLeft);
this.bottomLeftCollection.setScrollLeft(scrollLeft);
self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
},
_onWheelRight: function (deltaX, deltaY) {
var self = this; var self = this;
var scrollTop = this.bottomRightCollection.getScrollTop(); var scrollTop = this.bottomRightCollection.getScrollTop();
var scrollLeft = this.bottomRightCollection.getScrollLeft();
scrollTop += deltaY; scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftCollection.setScrollTop(scrollTop); this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop); this.bottomRightCollection.setScrollTop(scrollTop);
this.topRightCollection.setScrollLeft(scrollLeft);
this.bottomRightCollection.setScrollLeft(scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
}, },
_populateTable: function () { _populateTable: function () {
var self = this, o = this.options; var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -29691,26 +29738,54 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, {
mounted: function () { mounted: function () {
BI.QuickGridTable.superclass.mounted.apply(this, arguments); BI.QuickGridTable.superclass.mounted.apply(this, arguments);
var self = this; var self = this;
this._leftWheelHandler = new BI.WheelHandler( this._topLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._rightWheelHandler = new BI.WheelHandler( this._topRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this._bottomLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._bottomRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this.topLeftGrid.element.mousewheel(function (e) {
self._topLeftWheelHandler.onWheel(e.originalEvent);
});
this.topRightGrid.element.mousewheel(function (e) {
self._topRightWheelHandler.onWheel(e.originalEvent);
});
this.bottomLeftGrid.element.mousewheel(function (e) { this.bottomLeftGrid.element.mousewheel(function (e) {
self._leftWheelHandler.onWheel(e.originalEvent); self._bottomLeftWheelHandler.onWheel(e.originalEvent);
}); });
this.bottomRightGrid.element.mousewheel(function (e) { this.bottomRightGrid.element.mousewheel(function (e) {
self._rightWheelHandler.onWheel(e.originalEvent); self._bottomRightWheelHandler.onWheel(e.originalEvent);
}); });
}, },
_shouldHandleX: function (delta) { _shouldHandleLeftX: function (delta) {
return false; if (delta > 0) {
return this.bottomLeftGrid.getScrollLeft() < this.bottomLeftGrid.getMaxScrollLeft();
} else {
return this.bottomLeftGrid.getScrollLeft() > 0;
}
},
_shouldHandleRightX: function (delta) {
if (delta > 0) {
return this.bottomRightGrid.getScrollLeft() < this.bottomRightGrid.getMaxScrollLeft();
} else {
return this.bottomRightGrid.getScrollLeft() > 0;
}
}, },
_shouldHandleY: function (delta) { _shouldHandleY: function (delta) {
@ -29721,12 +29796,30 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, {
} }
}, },
_onWheelY: function (deltaX, deltaY) { _onWheelLeft: function (deltaX, deltaY) {
var self = this;
var scrollTop = this.bottomLeftGrid.getScrollTop();
var scrollLeft = this.bottomLeftGrid.getScrollLeft();
scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftGrid.setScrollTop(scrollTop);
this.bottomRightGrid.setScrollTop(scrollTop);
this.topLeftGrid.setScrollLeft(scrollLeft);
this.bottomLeftGrid.setScrollLeft(scrollLeft);
self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
},
_onWheelRight: function (deltaX, deltaY) {
var self = this; var self = this;
var scrollTop = this.bottomRightGrid.getScrollTop(); var scrollTop = this.bottomRightGrid.getScrollTop();
var scrollLeft = this.bottomRightGrid.getScrollLeft();
scrollTop += deltaY; scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftGrid.setScrollTop(scrollTop); this.bottomLeftGrid.setScrollTop(scrollTop);
this.bottomRightGrid.setScrollTop(scrollTop); this.bottomRightGrid.setScrollTop(scrollTop);
this.topRightGrid.setScrollLeft(scrollLeft);
this.bottomRightGrid.setScrollLeft(scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
}, },

71
src/base/table/table.collection.quick.js

@ -28,26 +28,54 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, {
mounted: function () { mounted: function () {
BI.QuickCollectionTable.superclass.mounted.apply(this, arguments); BI.QuickCollectionTable.superclass.mounted.apply(this, arguments);
var self = this; var self = this;
this._leftWheelHandler = new BI.WheelHandler( this._topLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._rightWheelHandler = new BI.WheelHandler( this._topRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._bottomLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this)
);
this._bottomRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this.topLeftCollection.element.mousewheel(function (e) {
self._topLeftWheelHandler.onWheel(e.originalEvent);
});
this.topRightCollection.element.mousewheel(function (e) {
self._topRightWheelHandler.onWheel(e.originalEvent);
});
this.bottomLeftCollection.element.mousewheel(function (e) { this.bottomLeftCollection.element.mousewheel(function (e) {
self._leftWheelHandler.onWheel(e.originalEvent); self._bottomLeftWheelHandler.onWheel(e.originalEvent);
}); });
this.bottomRightCollection.element.mousewheel(function (e) { this.bottomRightCollection.element.mousewheel(function (e) {
self._rightWheelHandler.onWheel(e.originalEvent); self._bottomRightWheelHandler.onWheel(e.originalEvent);
}); });
}, },
_shouldHandleX: function (delta) { _shouldHandleLeftX: function (delta) {
return false; if (delta > 0) {
return this.bottomLeftCollection.getScrollLeft() < this.bottomLeftCollection.getMaxScrollLeft();
} else {
return this.bottomLeftCollection.getScrollLeft() > 0;
}
},
_shouldHandleRightX: function (delta) {
if (delta > 0) {
return this.bottomRightCollection.getScrollLeft() < this.bottomRightCollection.getMaxScrollLeft();
} else {
return this.bottomRightCollection.getScrollLeft() > 0;
}
}, },
_shouldHandleY: function (delta) { _shouldHandleY: function (delta) {
@ -58,19 +86,38 @@ BI.QuickCollectionTable = BI.inherit(BI.CollectionTable, {
} }
}, },
_onWheelY: function (deltaX, deltaY) { _onWheelLeft: function (deltaX, deltaY) {
var self = this;
var scrollTop = this.bottomLeftCollection.getScrollTop();
var scrollLeft = this.bottomLeftCollection.getScrollLeft();
scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop);
this.topLeftCollection.setScrollLeft(scrollLeft);
this.bottomLeftCollection.setScrollLeft(scrollLeft);
self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
},
_onWheelRight: function (deltaX, deltaY) {
var self = this; var self = this;
var scrollTop = this.bottomRightCollection.getScrollTop(); var scrollTop = this.bottomRightCollection.getScrollTop();
var scrollLeft = this.bottomRightCollection.getScrollLeft();
scrollTop += deltaY; scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftCollection.setScrollTop(scrollTop); this.bottomLeftCollection.setScrollTop(scrollTop);
this.bottomRightCollection.setScrollTop(scrollTop); this.bottomRightCollection.setScrollTop(scrollTop);
this.topRightCollection.setScrollLeft(scrollLeft);
this.bottomRightCollection.setScrollLeft(scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
}, },
_populateTable: function () { _populateTable: function () {
var self = this, o = this.options; var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {

68
src/base/table/table.grid.quick.js

@ -28,26 +28,54 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, {
mounted: function () { mounted: function () {
BI.QuickGridTable.superclass.mounted.apply(this, arguments); BI.QuickGridTable.superclass.mounted.apply(this, arguments);
var self = this; var self = this;
this._leftWheelHandler = new BI.WheelHandler( this._topLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._rightWheelHandler = new BI.WheelHandler( this._topRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelY, this), BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleX, this), BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this) BI.bind(this._shouldHandleY, this)
); );
this._bottomLeftWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelLeft, this),
BI.bind(this._shouldHandleLeftX, this),
BI.bind(this._shouldHandleY, this)
);
this._bottomRightWheelHandler = new BI.WheelHandler(
BI.bind(this._onWheelRight, this),
BI.bind(this._shouldHandleRightX, this),
BI.bind(this._shouldHandleY, this)
);
this.topLeftGrid.element.mousewheel(function (e) {
self._topLeftWheelHandler.onWheel(e.originalEvent);
});
this.topRightGrid.element.mousewheel(function (e) {
self._topRightWheelHandler.onWheel(e.originalEvent);
});
this.bottomLeftGrid.element.mousewheel(function (e) { this.bottomLeftGrid.element.mousewheel(function (e) {
self._leftWheelHandler.onWheel(e.originalEvent); self._bottomLeftWheelHandler.onWheel(e.originalEvent);
}); });
this.bottomRightGrid.element.mousewheel(function (e) { this.bottomRightGrid.element.mousewheel(function (e) {
self._rightWheelHandler.onWheel(e.originalEvent); self._bottomRightWheelHandler.onWheel(e.originalEvent);
}); });
}, },
_shouldHandleX: function (delta) { _shouldHandleLeftX: function (delta) {
return false; if (delta > 0) {
return this.bottomLeftGrid.getScrollLeft() < this.bottomLeftGrid.getMaxScrollLeft();
} else {
return this.bottomLeftGrid.getScrollLeft() > 0;
}
},
_shouldHandleRightX: function (delta) {
if (delta > 0) {
return this.bottomRightGrid.getScrollLeft() < this.bottomRightGrid.getMaxScrollLeft();
} else {
return this.bottomRightGrid.getScrollLeft() > 0;
}
}, },
_shouldHandleY: function (delta) { _shouldHandleY: function (delta) {
@ -58,12 +86,30 @@ BI.QuickGridTable = BI.inherit(BI.GridTable, {
} }
}, },
_onWheelY: function (deltaX, deltaY) { _onWheelLeft: function (deltaX, deltaY) {
var self = this;
var scrollTop = this.bottomLeftGrid.getScrollTop();
var scrollLeft = this.bottomLeftGrid.getScrollLeft();
scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftGrid.setScrollTop(scrollTop);
this.bottomRightGrid.setScrollTop(scrollTop);
this.topLeftGrid.setScrollLeft(scrollLeft);
this.bottomLeftGrid.setScrollLeft(scrollLeft);
self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
},
_onWheelRight: function (deltaX, deltaY) {
var self = this; var self = this;
var scrollTop = this.bottomRightGrid.getScrollTop(); var scrollTop = this.bottomRightGrid.getScrollTop();
var scrollLeft = this.bottomRightGrid.getScrollLeft();
scrollTop += deltaY; scrollTop += deltaY;
scrollLeft += deltaX;
this.bottomLeftGrid.setScrollTop(scrollTop); this.bottomLeftGrid.setScrollTop(scrollTop);
this.bottomRightGrid.setScrollTop(scrollTop); this.bottomRightGrid.setScrollTop(scrollTop);
this.topRightGrid.setScrollLeft(scrollLeft);
this.bottomRightGrid.setScrollLeft(scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); this.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
}, },

Loading…
Cancel
Save