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-margin #51

Closed
macakronos opened this issue Jan 25, 2022 · 3 comments
Closed

Support scroll-margin #51

macakronos opened this issue Jan 25, 2022 · 3 comments

Comments

@macakronos
Copy link

I can think of it to be with a css variable.

Currently scroll-margin. It doesn't work in Safari, so to solve that need I came up with that option. Thank you for your contribution to the community.

@jonaskuske jonaskuske changed the title Is it possible to add an option for offset? Support scroll-margin Feb 15, 2022
@jonaskuske
Copy link
Owner

Same situation as #34 (comment) :)
(though I must say I'll look into scroll-padding first as I think it's more common, mostly for fixed headers)

@jonaskuske
Copy link
Owner

Good news, found out that scroll-margin support is implemented by https://github.com/magic-akari/seamless-scroll-polyfill, a more modern (and larger) fork of https://github.com/iamdustan/smoothscroll.

So if you use that in tandem with smoothscroll-anchor-polyfill, scroll-margin is supported. For example:

<script src="https://unpkg.com/[email protected]/lib/bundle.min.cjs"></script>
<script src="https://unpkg.com/[email protected]/dist/index.min.js"></script>
<script>
// enable seamless-scroll-polyfill
seamless.polyfill()
</script>

Note that in Safari < 14.5 scroll-margin is called scroll-snap-margin, so if you support older Safari versions you'll need to add that property as well.

@macakronos
Copy link
Author

Excellent. Thanks jonaskuske.

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

No branches or pull requests

2 participants