diff options
author | srichman333 <sarah_n_richman@brown.edu> | 2023-10-02 17:54:58 -0400 |
---|---|---|
committer | srichman333 <sarah_n_richman@brown.edu> | 2023-10-02 17:54:58 -0400 |
commit | 3884211ab83db30965a4dc1c4b3133684904ebb9 (patch) | |
tree | ece92e95ee728e2ad6908c74d506ab6d567e3bb9 /src/client/views/nodes/DataVizBox/components/TableBox.tsx | |
parent | 1256010bee4d427d35f5ccb13d7ba08b424df3e5 (diff) |
better scrolling in data tables
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')
-rw-r--r-- | src/client/views/nodes/DataVizBox/components/TableBox.tsx | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx index 556a8b281..dd13c5749 100644 --- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx +++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx @@ -32,7 +32,7 @@ interface TableBoxProps { @observer export class TableBox extends React.Component<TableBoxProps> { @observable startID: number = 0; - @observable endID: number = 20; + @observable endID: number = 15; _inputChangedDisposer?: IReactionDisposer; componentDidMount() { @@ -90,33 +90,29 @@ export class TableBox extends React.Component<TableBoxProps> { } } if (useCell && useContainer){ - - // check for 20 (inital value) as end point - if (this.endID == 20){ - let newEnd = this.startID + useContainer.getBoundingClientRect().height / useCell.getBoundingClientRect().height + 1; - newEnd = Math.floor(Number(newEnd)) - if (newEnd<this.endID){ this.endID -= .1; } - if (newEnd>this.endID && this.endID<=this._tableDataIds.length) { this.endID += .1; } - } - + let atEnd = false; // top - if (useContainer.scrollTop <= 10 && this.startID >= -1){ - this.startID -= .01; - this.endID -= .01; + if (useContainer.scrollTop <= 10){ + atEnd = true; + if (this.startID >= -1){ + this.startID -= .001; + this.endID -= .001; + } } - // bottom - else if (useContainer.scrollHeight - 50 <= useContainer.scrollTop + useContainer.getBoundingClientRect().height && this.endID<=this._tableDataIds.length){ - this.startID += .01; - this.endID += .01; + else if (useContainer.scrollHeight / (useContainer.scrollTop + useContainer.getBoundingClientRect().height) < 1.1 && this.endID<=this._tableDataIds.length){ + this.startID += .015; + this.endID += .015; } - // regular scroll - else { - let newStart = (useContainer.scrollTop / useCell.getBoundingClientRect().height ) - 1; - newStart = Math.floor(Number(newStart)) - if (newStart<this.startID && this.startID>=-1){ this.startID -= .01; this.endID -= -.01; } - else if (newStart>this.startID) { this.startID += .01; this.endID += .01; } + else if (this.endID<=this._tableDataIds.length && !atEnd) { + let newStart = (useContainer.scrollTop / useCell.getBoundingClientRect().height ) ; + if (newStart<this.startID && this.startID>=-1){ + this.startID -= .001; + this.endID -= .001; } + else if (newStart>this.startID) { + this.startID += .001; + this.endID += .001; } } } else { |