scrollIntoView or linking to a scroll anchor on a sticky element should scroll to the normal flow position. |
||
Issue descriptionVersion: 56.0.2915.0 OS: All We currently scroll to the current position of sticky elements when trying to scroll them into view. This matches Firefox and Safari, but I believe is not the desired behavior because scrolling to that sticky element can then move it such that scrolling to it again moves again. Additionally, sticky position top is often used at the beginning of section headers, it makes sense that scrolling to the section header should scroll to the top of the section. I think we should instead scroll to the normal flow position of the sticky element as this is a stable anchor point and I think makes more sense for a lot of use cases. I will add some motivating examples to demonstrate this.
,
Nov 10 2016
I agree that's probably the most useful use case. The counter-argument to me would be that we're changing the semantics of scrollIntoView based on positioning type which seems like it'd hurt platform predictability (admittedly minorly). Perhaps adding an option in scrollIntoViewOptions maybe another approach?
,
Jan 23 2017
,
Jan 23 2017
FYI there is also the example of http://output.jsbin.com/lukekot/15, where scrollIntoView() will increment the scroll offset to try and place the sticky at the top of the page. The sticky will then move to be properly offset for its constraints, and calling scrollIntoView() will increment the scroll offset again. Ad infinitum ;)
,
Jan 23 2017
I'm not sure that this is all that different than scrollIntoView being a no-op on a fixed position element. The spec for scrollIntoView doesn't seem to make an exemption for fixed position (see https://drafts.csswg.org/cssom-view/#element-scrolling-members) which means that technically we should be attempting to scroll to its bounding client rect (like we currently do for sticky) even though scrolling to it means it will get pushed further down (which can also happen with sticky). Of course I would like to see consistent behavior between browsers so it'd be great to standardize the stable scroll into view behavior for fixed and sticky position elements.
,
May 23 2017
I filed https://github.com/w3c/csswg-drafts/issues/1459 to discuss changing this in the spec. |
||
►
Sign in to add a comment |
||
Comment 1 by flackr@chromium.org
, Nov 10 2016