scroll-into-view / compute-scroll-into-view

Utility for calculating what should be scrolled, how it's scrolled is up to you
https://scroll-into-view.dev#scroll-alignment
MIT License
313 stars 27 forks source link

Question about current status of scroll-padding / scroll-margin #831

Open floer32 opened 2 years ago

floer32 commented 2 years ago

I saw this mentioned in an earlier issue (#292):

I plan on implementing scroll-margin and scroll-padding support next, as these properties are no longer exclusive to scroll-snap logic but also affect scrollIntoView and page fragment scrolling in firefox and chrome betas.

And I gather that explicit support has not been implemented yet, based on searching the source code.

I noticed that, without the polyfill, I can use .scrollIntoView in Chrome (just without the if-needed option), and it's working as I expect, taking scroll-padding-top into account. So my solution for now is: in Chrome, just call that native method, but if we are in Safari/Edge (or if that method had an error), it uses this polyfill (even though some content will be covered by the fixed header, since scroll-padding/scroll-margin is not accounted-for yet).

Is that basically the right idea in the meantime?

jknight12882 commented 2 years ago

would also like to see support for scroll-padding and scroll-margin

stipsan commented 1 year ago

Adding some context, these are the tests that needs to be added, and the implementation need to pass: