Skip to content

Commit

Permalink
Don't add bottom padding for overscroll
Browse files Browse the repository at this point in the history
  • Loading branch information
jassmith committed Feb 17, 2021
1 parent 5f76c34 commit 28a56e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/data-editor/data-editor-stories.tsx
Expand Up @@ -244,3 +244,26 @@ export function Draggable() {
/>
);
}

export function IdealSize() {
// trying to be 500x500
const cols: GridColumn[] = [
{ title: "Number", width: 250 },
{ title: "Square", width: 250 },
];
return (
<DataEditor
isDraggable={true}
onDragStart={args => {
args.setData("text", "testing");
}}
getCellContent={getData}
columns={cols}
rowHeight={50}
headerHeight={50}
showTrailingBlankRow={false}
rowMarkers={false}
rows={9}
/>
);
}
5 changes: 2 additions & 3 deletions src/scrolling-data-grid/scrolling-data-grid.tsx
Expand Up @@ -28,12 +28,11 @@ const GridScroller: React.FunctionComponent<ScrollingDataGridProps> = p => {

let height = headerHeight;
if (typeof rowHeight === "number") {
height += rows * rowHeight + rowHeight / 2;
height += rows * rowHeight;
} else {
for (let r = 0; r < rows; r++) {
height += rowHeight(r);
}
height += rowHeight(rows - 1) / 2;
}

const onScrollUpdate = React.useCallback(
Expand Down Expand Up @@ -63,7 +62,7 @@ const GridScroller: React.FunctionComponent<ScrollingDataGridProps> = p => {
let cellY = 0;
let cellBottom = 0;
if (typeof rowHeight === "number") {
cellY = Math.round(args.scrollTop / rowHeight);
cellY = Math.ceil(args.scrollTop / rowHeight);
cellBottom = Math.ceil(args.clientHeight / rowHeight) + cellY;
} else {
let y = 0;
Expand Down

0 comments on commit 28a56e9

Please sign in to comment.