Skip to content

[cssom-view] Add scrollIntoView parameter to only scroll the nearest scrolling container #10451

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

Closed
flackr opened this issue Jun 14, 2024 · 3 comments

Comments

@flackr
Copy link
Contributor

flackr commented Jun 14, 2024

Right now the cssom-view spec says that (emphasis mine):

To scroll a target into view target, which is an Element or Range, with a scroll behavior behavior, a block flow direction position block, and an inline base direction position inline, means to run these steps for each ancestor element or viewport that establishes a scrolling box scrolling box, in order of innermost to outermost scrolling box:

There are many use cases when building components where it would be nice to only scroll the scroller associated with that component. I propose we add a property to ScrollIntoViewOptions which limits the scroll to only the nearest scrolling container. E.g.

dictionary ScrollIntoViewOptions : ScrollOptions {
  ScrollLogicalPosition block = "start";
  ScrollLogicalPosition inline = "nearest";
  RecursionBehavior scrollers = "all" | "nearest";
};

I thought this was already filed but I couldn't find it in search so filing again.

Options to consider:

  1. A named parameter, e.g. scrollers = "all" | "nearest"
  2. A boolean parameter, e.g. recurse = true | false
  3. A capturing ancestor scroller node, e.g. Element? contain = document.scrollingElement

We could also have some combination of these options, e.g. the the named parameter could optionally take an element.

@argyleink
Copy link
Contributor

many many folks at CSS Day expressed this as an issue, as the API is what they want, but the side effects of effecting each ancestor are not what they want.

there's also scrollIntoViewIfNeeded() that could use the same property

@rol4nd909
Copy link

Yep I was one of them 😊 love to see this coming as an option. Thanks for working on it.

@flackr
Copy link
Contributor Author

flackr commented Oct 30, 2024

Apologies I think this is a duplicate of #9452 so I'll close in favor of that tracking issue which has a bit more history.

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

3 participants