Skip to content
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

Implement fallback of scroll stabilizer to reduce scroll jumping while editing #251

Closed
wants to merge 2 commits into from

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Jun 11, 2021

For keeping extension sustainabillity, Marp for VS Code has not any scroll-sync logic and relies to VS Code's built-in preview script. Scroll sync is working correctly in almost cases, but sometimes the preview pane brings unexpected scroll when updated webview by editing.

When updating preview, VS Code is trying to restore the previous scroll position by calling scrollTo on loading. A timing of execution this script is same as other extensions contributed scripts included Marp. However, they will run in unpredictable order because they are injected through <script async>. If VS Code ran built-in initialization script before Marp's preview script, a calculated scroll position for stabilization would be wrong due to its styles are based on what have not applied Marp specific styles. On the other hand, the built-in scroll stabilization will work to Marp slides perfectly if ran Marp preview script before built-in script. This is reason why user occasionally see to unexpected scroll.

This PR implemented a fallback logic of scroll stabilizer to reduce scroll jumping while editing. It does not always apply the updated scroll position. If built-in preview script has not run on running Marp script, the scroll position will override with the built-in logic. And the fallback will be disabled temporally if changed the number of pages.

It would not resolve #248 completely, but can reduce furastrating jumps while editing text. It might be related to #173 too.

@yhatt
Copy link
Member Author

yhatt commented Jun 15, 2021

Close this in favor of #252.

@yhatt yhatt closed this Jun 15, 2021
@yhatt yhatt deleted the scroll-stabilizer-fallback branch June 15, 2021 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The previewed slide page keeps jumpping when I edit the markdown document
1 participant