-
Notifications
You must be signed in to change notification settings - Fork 6.3k
editor: Smooth scrolling #44827
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
base: main
Are you sure you want to change the base?
editor: Smooth scrolling #44827
Conversation
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
|
Thanks for this PR, feels smooth. Are there any plans to integrate this into vim-mode as well? (e.g., or is this not part of this PR? |
|
@niekdomi yep, I still need to make the changes. I'm currently perfecting the scroll animation |
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
the set_scroll_position of the editor saves to the db the position and creates event which is wasteful for an animation Signed-off-by: Marco Mihai Condrache <[email protected]>
| update.position, &snapshot, cx, | ||
| ); | ||
|
|
||
| window.request_animation_frame(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this isn’t the ideal approach for animations, especially in the editor, since it causes the whole entity to re-render. That said, in practice it doesn’t seem to make a noticeable difference right now.
The current scrolling implementation in the editor already calls cx.notify() on every scroll event, so the animation isn’t doing anything fundamentally different in that regard. In fact, it may even be slightly more efficient, since we avoid updating the db and emitting events until the animation has finished, which is the opposite of how the current scroll handling works.
I’m very open to improving this if you think there’s a better direction, but wanted to share the reasoning behind the current approach
Signed-off-by: Marco Mihai Condrache <[email protected]>
Closes #4355
This is still a WIP, but it already works well. At 240 fps, it feels smooth like butter.
Ref: https://pavelfatin.com/scrolling-with-pleasure
Release Notes: