Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support scroll-padding #34

Open
powerbuoy opened this issue Feb 28, 2020 · 11 comments
Open

Support scroll-padding #34

powerbuoy opened this issue Feb 28, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@powerbuoy
Copy link

Any chance you could add support for scroll-padding?

@jonaskuske jonaskuske added the enhancement New feature or request label Feb 29, 2020
@jonaskuske
Copy link
Owner

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

@kahl-dev
Copy link

Would love to see this happen

@austincarpenter
Copy link

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

@DavidLindsey0118
Copy link

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

@jonaskuske
Copy link
Owner

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!

@DavidLindsey0118
Copy link

DavidLindsey0118 commented Feb 15, 2022 via email

@DavidLindsey0118
Copy link

DavidLindsey0118 commented Feb 15, 2022 via email

@jonaskuske
Copy link
Owner

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 */
}

@DavidLindsey0118
Copy link

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

@jonaskuske
Copy link
Owner

@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)

@DavidLindsey0118
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants