Skip to content

Commit 799344b

Browse files
author
David Kutugata
authored
Turned the check of the scroll at the bottom from … (#7259)
checking equal to checking a range to make it work with fractions.
1 parent 8773f63 commit 799344b

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

news/2 Fixes/6580.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Still the interactive window will snap to the bottom if you already are at the b
33
Tested to work with:
44
- regular code
55
- dataframes
6-
- big and regular plots
6+
- big and regular plots
7+
Turned the check of the scroll at the bottom from checking equal to checking a range to make it work with fractions.

src/datascience-ui/history-react/MainPanel.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,12 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
169169
public scrollDiv = (div: HTMLDivElement) => {
170170
if (this.state.isAtBottom) {
171171
this.internalScrollCount += 1;
172+
// Force auto here as smooth scrolling can be canceled by updates to the window
173+
// from elsewhere (and keeping track of these would make this hard to maintain)
172174
div.scrollIntoView({ behavior: 'auto', block: 'start', inline: 'nearest' });
173175
}
174176
}
175177

176-
public handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
177-
if (this.internalScrollCount > 0) {
178-
this.internalScrollCount -= 1;
179-
} else {
180-
this.setState({
181-
isAtBottom: e.currentTarget.scrollHeight - e.currentTarget.scrollTop === e.currentTarget.clientHeight
182-
});
183-
}
184-
}
185-
186178
// tslint:disable-next-line:no-any cyclomatic-complexity max-func-body-length
187179
public handleMessage = (msg: string, payload?: any) => {
188180
switch (msg) {
@@ -287,6 +279,18 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
287279
return false;
288280
}
289281

282+
private handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
283+
if (this.internalScrollCount > 0) {
284+
this.internalScrollCount -= 1;
285+
} else {
286+
const currentHeight = e.currentTarget.scrollHeight - e.currentTarget.scrollTop;
287+
const isAtBottom = currentHeight < e.currentTarget.clientHeight + 2 && currentHeight > e.currentTarget.clientHeight - 2;
288+
this.setState({
289+
isAtBottom
290+
});
291+
}
292+
}
293+
290294
// Uncomment this to use for debugging messages. Add a call to this to stick in dummy sys info messages.
291295
// private addDebugMessageCell(message: string) {
292296
// const cell: ICell = {

0 commit comments

Comments
 (0)