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

New scroll align mode: 'smart' #209

Merged
merged 1 commit into from
Apr 12, 2019
Merged

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Apr 12, 2019

This adds implementation + tests. I can write the docs if you'd like them to be a part of the PR.

The purpose is to add a new scrolling mode called smart. We may make it default in v2 if we want.

It behaves like auto when the target is within a single screen from the viewport boundaries, and behaves like center otherwise. The rationale is that if something is far enough, there's no meaningful context to preserve — and therefore we might as well center it.

In particular, centering is helpful for cases when the next selected item is relatively random (such as with "find by DOM node" picker in DevTools). In that case, the auto behavior often jumps between the top and the bottom selected nodes because we're not necessarily scrolling in any particular direction. However, the smart behavior tries to center things unless we're already pretty close to them.

Before

Screen Recording 2019-04-12 at 06 09 PM

After

Screen Recording 2019-04-12 at 06 08 PM

@bvaughn
Copy link
Owner

bvaughn commented Apr 12, 2019

Thanks Dan! I updated the docs site.

Published as v1.8.0

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.

None yet

2 participants