forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
check the position of the scroll in the interactive #7198
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
DavidKutu
merged 3 commits into
master
from
davidkutu/prevent_interactive_window_from_snapping_to_bottom
Sep 5, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Changed the way scrolling is treated. Now we only check for the position of the scroll, the size of the cell won't matter. | ||
Still the interactive window will snap to the bottom if you already are at the bottom, and will stay in place if you are not. Like a chat window. | ||
Tested to work with: | ||
- regular code | ||
- dataframes | ||
- big and regular plots |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState> | |
private stackLimit = 10; | ||
private updateCount = 0; | ||
private renderCount = 0; | ||
private internalScrollCount = 0; | ||
private editCellRef: Cell | null = null; | ||
private mainPanel: HTMLDivElement | null = null; | ||
private variableExplorerRef: React.RefObject<VariableExplorer>; | ||
|
@@ -68,7 +69,8 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState> | |
editorOptions: this.computeEditorOptions(), | ||
currentExecutionCount: 0, | ||
debugging: false, | ||
enableGather: getSettings && getSettings().enableGather | ||
enableGather: getSettings && getSettings().enableGather, | ||
isAtBottom: true | ||
}; | ||
|
||
// Add test state if necessary | ||
|
@@ -151,7 +153,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState> | |
<section id='main-panel-variable' aria-label={getLocString('DataScience.collapseVariableExplorerLabel', 'Variables')}> | ||
{this.renderVariablePanel(baseTheme)} | ||
</section> | ||
<main id='main-panel-content'> | ||
<main id='main-panel-content' onScroll={this.handleScroll}> | ||
{this.renderContentPanel(baseTheme)} | ||
</main> | ||
<section id='main-panel-footer' aria-label={getLocString('DataScience.editSection', 'Input new cells here')}> | ||
|
@@ -161,6 +163,26 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState> | |
); | ||
} | ||
|
||
// This handles the scrolling. Its called from the props of contentPanel. | ||
// We only scroll when the state indicates we are at the bottom of the interactive window, | ||
// otherwise it sometimes scrolls when the user wasn't at the bottom. | ||
public scrollDiv = (div: HTMLDivElement) => { | ||
if (this.state.isAtBottom) { | ||
this.internalScrollCount += 1; | ||
div.scrollIntoView({ behavior: 'auto', block: 'start', inline: 'nearest' }); | ||
} | ||
} | ||
|
||
public handleScroll = (e: React.UIEvent<HTMLDivElement>) => { | ||
if (this.internalScrollCount > 0) { | ||
this.internalScrollCount -= 1; | ||
} else { | ||
this.setState({ | ||
isAtBottom: e.currentTarget.scrollHeight - e.currentTarget.scrollTop === e.currentTarget.clientHeight | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to check does this need any wiggle room in it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel its confusing, it sticks if you are all the way on the bottom. If not it stays there. |
||
}); | ||
} | ||
} | ||
|
||
// tslint:disable-next-line:no-any cyclomatic-complexity max-func-body-length | ||
public handleMessage = (msg: string, payload?: any) => { | ||
switch (msg) { | ||
|
@@ -445,7 +467,8 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState> | |
openLink: this.openLink, | ||
expandImage: this.showPlot, | ||
gatherCode: this.gatherCode, | ||
enableGather: this.state.enableGather | ||
enableGather: this.state.enableGather, | ||
scrollToBottom: this.scrollDiv | ||
}; | ||
} | ||
private getToolbarProps = (baseTheme: string): IToolbarPanelProps => { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.