Skip to content

What does "nearest" mean for scrollBehavior? #5486

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

Open
verheyenkoen opened this issue Sep 21, 2023 · 2 comments
Open

What does "nearest" mean for scrollBehavior? #5486

verheyenkoen opened this issue Sep 21, 2023 · 2 comments

Comments

@verheyenkoen
Copy link
Contributor

Subject

Guides

Description

The Actionabiliy page (and a few other pages) mentions the "nearest" option for scrollBehavior but I can't find a definition for that. Does that mean the parent node (like "closest" in jQuery/Cypress)? The other options are more self-descriptive but "nearest" is a bit smoky so I'd like that clarified.

@litera
Copy link

litera commented Jan 22, 2025

I haven't noticed aby documentation change that would clear these things up. So what is the meaning of nearest then?

@verheyenkoen
Copy link
Contributor Author

FYI: I just got familiar with the scrollIntoView method and -I assume- this relates to the block option from that method that has the same options. Possibly both block and inline are set with this option.

So this defines how the scrollable container behaves when moving the hidden element into view in the "block"-dimension (usually vertical). Nearest would mean it brings the element fully into view on the nearest side. Think of: the minimum amount of scrolling needed to bring it into view. So if the element was below the scrollable viewport it will scroll it to the bottom. If it was above the scrollable viewport, it will scroll it to the top.

Still think the docs could be approved to at least link to the MDN page for the scrollIntoView() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants