Skip to content

[cssom-view][css-position] Scrolling a sticky element into view should use normal flow position for sticky boxes #1459

@flackr

Description

@flackr

To scroll an element into view the spec says that you should use the element's bounding border box returned from getBoundingClientRect. For sticky elements which are currently sticking trying to scroll to their current position could result in them moving further away or not being visible due to multiple similar sticky elements (e.g. click on the boxes or anchor links after scrolling down on http://jsbin.com/simivof/edit?html,output). This pattern of the previous sticky title being covering up the next one seems to be a common one.

I think the expected behavior when trying to scroll to a sticky element, at least by anchor, and probably also for scrollIntoView, would be to scroll to the element's normal flow position before applying the sticky offset. This will be a stable position and is most likely to result in the element actually being visible. It's actually hard to get this behavior otherwise as if you wrap a box around the sticky element for an anchor it will contain it and prevent the sticky element from moving.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions