Intent to Prototype: ScrollIntoView container option

122 views
Skip to first unread message

Chromestatus

unread,
Feb 11, 2025, 5:06:55 PMFeb 11
to blin...@chromium.org, fla...@chromium.org

Contact emails

fla...@chromium.org

Explainer

None

Specification

https://drafts.csswg.org/cssom-view/#dom-scrollintoviewoptions-container

Summary

The ScrollIntoViewOptions container option allows developers to perform a scrollIntoView only scrolling the nearest ancestor scroll container. For example, the following snippet only scrolls the scroll container of target to bring target into view, but will not scroll all of the scroll containers to the viewport: target.scrollIntoView({container: 'nearest'});



Blink component

Blink>Scroll

Motivation

The scrollIntoView API is extremely useful to scroll an element into view respecting things like scroll snapping, scroll margins, etc without the developer needing to calculate the resulting offset. However, it currently scrolls every scroll container all the way to the viewport. This is counter-intuitive when building components in that it hijacks the user's attention to the thing being scrolled into view even if the component may not have intended to do so.



Initial public proposal

https://github.com/w3c/csswg-drafts/issues/9452

TAG review

None

TAG review status

Pending

Risks



Interoperability and Compatibility

None



Gecko: No signal

WebKit: No signal

Web developers: No signals

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None



Is this feature fully tested by web-platform-tests?

No

Flag name on about://flags

None

Finch feature name

None

Non-finch justification

None

Requires code in //chrome?

False

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5100036528275456?gate=5148755550273536

This intent message was generated by Chrome Platform Status.
Reply all
Reply to author
Forward
0 new messages