Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/qooxdoo/qxl.datagrid
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalinowski-vmn committed Apr 12, 2024
2 parents 0eff6b0 + d22c75a commit be00816
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions source/class/qxl/datagrid/DataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,29 @@ qx.Class.define("qxl.datagrid.DataGrid", {
* @returns
*/
_onRoll(e) {
e.stop();
const SCROLLING_SPEED = 0.08;
// only wheel and touch
if (e.getPointerType() == "mouse") {
e.stop();
return;
}

if (this.__cancelRoll && e.getMomentum()) {
e.stopMomentum();
this.__cancelRoll = null;
e.stop();
return;
}

let rowCount = this.getDataSourceSize().getRow();
var newStartRowIndex = this.getStartRowIndex() + Math.floor(e.getDelta().y * SCROLLING_SPEED);
let maxRows = this.getMaxRows();
newStartRowIndex = qxl.datagrid.util.Math.clamp(0, Math.max(0, rowCount - maxRows), newStartRowIndex);

const isAtScrollLimit = newStartRowIndex == this.getStartRowIndex();
if (!isAtScrollLimit) {
e.stop();
}
this.setStartRowIndex(newStartRowIndex);
},

Expand All @@ -383,7 +389,14 @@ qx.Class.define("qxl.datagrid.DataGrid", {
*/
getMaxRows() {
const styling = this.__sizeCalculator.getStyling();
return Math.floor(this.getQxObject("oddEvenRows").getBounds().height / (styling.getMaxRowHeight() ?? styling.getMinRowHeight())) - 4;
const oddEvenBounds = this.getQxObject("oddEvenRows").getBounds();
if (oddEvenBounds && "height" in oddEvenBounds) {
return Math.floor(oddEvenBounds.height / (styling.getMaxRowHeight() ?? styling.getMinRowHeight())) - 4;
}
if (qx.core.Environment.get("qx.debug")) {
this.warn(`${this.classname}.getMaxRows called too early, assuming maximum of zero rows`);
}
return 0;
},

/**
Expand Down

0 comments on commit be00816

Please sign in to comment.