Skip to content

Commit

Permalink
Add infinite scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
CannonLock committed Dec 18, 2023
1 parent 529f8bc commit d5d4b96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/pages/maps/@id/edit/components/main.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
position: relative

.width-adjustable-panel-content
display: flex
flex-direction: column
overflow: scroll
height: 100%
flex-grow: 1
Expand Down
14 changes: 13 additions & 1 deletion src/pages/maps/@id/edit/edit-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function TableInterface({ url }: EditTableProps) {
const [copiedColumn, setCopiedColumn] = useState<string | undefined>(undefined)

// Data State
const [dataParameters, setDataParameters] = useState<DataParameters>({select: {page: "0", pageSize: "99"}, filter: {}})
const [dataParameters, setDataParameters] = useState<DataParameters>({select: {page: "0", pageSize: "50"}, filter: {}})
const [data, setData] = useState<any[]>([])

// Error State
Expand Down Expand Up @@ -338,6 +338,9 @@ export default function TableInterface({ url }: EditTableProps) {
onKeyDown: handleKeyDown,
onKeyUp: handleKeyUp,
tabIndex: 0,
style: {
minHeight: "0"
}
}, [
h("div.table-container", {}, [
h.if(error != undefined)("div.warning", {}, [error]),
Expand Down Expand Up @@ -378,6 +381,15 @@ export default function TableInterface({ url }: EditTableProps) {
setSelectedColumn(undefined)
}
},
onVisibleCellsChange: (visibleCells) => {

console.log(visibleCells)
if(visibleCells["rowIndexEnd"] > parseInt(dataParameters.select.pageSize) - 10){
const newPageSize = (parseInt(dataParameters.select.pageSize) + 50).toString()

setDataParameters({...dataParameters, select: {...dataParameters.select, pageSize: newPageSize}})
}
},
numRows: data.length,
// Dumb hacks to try to get the table to rerender on changes
cellRendererDependencies: [data, tableUpdates],
Expand Down

0 comments on commit d5d4b96

Please sign in to comment.