Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix scrolling #5747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/5560.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change scrolling to not animate to workaround async updates breaking the animation.
60 changes: 39 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 6 additions & 16 deletions src/datascience-ui/history-react/contentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface IContentPanelProps {
}

export class ContentPanel extends React.Component<IContentPanelProps> {
private bottom: HTMLDivElement | undefined;
private bottomRef: React.RefObject<HTMLDivElement> = React.createRef<HTMLDivElement>();
constructor(prop: IContentPanelProps) {
super(prop);
}
Expand All @@ -51,7 +51,7 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
{this.renderCells()}
</div>
</div>
<div ref={this.updateBottom}/>
<div ref={this.bottomRef}/>
</div>
);
}
Expand Down Expand Up @@ -88,20 +88,10 @@ export class ContentPanel extends React.Component<IContentPanelProps> {
}

private scrollToBottom = () => {
if (this.bottom && this.bottom.scrollIntoView && !this.props.skipNextScroll && !this.props.testMode) {
// Delay this until we are about to render. React hasn't setup the size of the bottom element
// yet so we need to delay. 10ms looks good from a user point of view
setTimeout(() => {
if (this.bottom) {
this.bottom.scrollIntoView({behavior: 'smooth', block : 'end', inline: 'end'});
}
}, 100);
}
}

private updateBottom = (newBottom: HTMLDivElement) => {
if (newBottom !== this.bottom) {
this.bottom = newBottom;
if (this.bottomRef.current && !this.props.skipNextScroll && !this.props.testMode) {
// Force auto here as smooth scrolling can be canceled by updates to the window
// from elsewhere (and keeping track of these would make this hard to maintain)
this.bottomRef.current.scrollIntoView({behavior: 'auto', block: 'start', inline: 'nearest'});
}
}

Expand Down