jonaskuske/smoothscroll-anchor-polyfill

Support scroll-padding

Opened this issue ยท 11 comments

Any chance you could add support for scroll-padding?

Yep, sounds very useful โ€“ didn't know this property existed!
Will look into it :)

Would love to see this happen

Any update on this one? I'm assuming this would include scroll-margin too?

Chiming in, this would be extremely helpful...running into lots of issues with fixed mobile navigation cutting off the top of sections because the lib does not respect scroll-margin or scroll-padding in CSS

Hey, just to give you a quick heads-up:
I'll look into it this week, but can't promise anything as of now, as it might be actually quite complicated to make this happen given the current implementation (which just calls .scrollIntoView() and is not concerned with individual scrolls). I have some ideas though, so we'll see!

Nothing new for scroll-padding, BUT scroll-margin is supported when this lib is used in tandem with seamless-scroll-polyfill: #51 (comment)

So you can apply a scroll margin to the scrollable/targetable elements (instead of a padding for the scroll container) and avoid the mobile navigation issue:

/* Doesn't work (yet) ๐Ÿ‘Ž */
.scroll-container {
  scroll-padding-top: 100px; /* adjust for fixed navigation */
}

/* Works ๐Ÿ‘ */
[id] {
  scroll-margin-top: 100px; /* adjust for fixed navigation */
}

How can I pull that in? I don't see a newer version on npmjs: https://www.npmjs.com/package/smoothscroll-anchor-polyfill

@DavidLindsey0118 No new version of smoothscroll-anchor-polyfill needed, support for scroll-margin is achieved by replacing smoothscroll-polyfill with seamless-scroll-polyfill. (then initializing the latter via seamless.polyfill())
See here: #51 (comment)

Thank you, I figured it out. For posterity, using NPM, I also had to make sure I was using the latest version of seamless-scroll-polyfill (2.1.8) and also had to implement it via the directions in the README.MD (also here: https://www.npmjs.com/package/seamless-scroll-polyfill under "Use polyfill to patch all methods")

Thanks!