smoothscroll-anchor-polyfill icon indicating copy to clipboard operation
smoothscroll-anchor-polyfill copied to clipboard

Support scroll-padding

Open powerbuoy opened this issue 4 years ago • 11 comments

Any chance you could add support for scroll-padding?

powerbuoy avatar Feb 28 '20 15:02 powerbuoy

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

jonaskuske avatar Mar 01 '20 15:03 jonaskuske

Would love to see this happen

kahl-dev avatar Jun 11 '21 12:06 kahl-dev

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

austincarpenter avatar Jan 24 '22 05:01 austincarpenter

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

DavidLindsey0118 avatar Feb 15 '22 18:02 DavidLindsey0118

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!

jonaskuske avatar Feb 15 '22 20:02 jonaskuske

That would be incredible, thank you!

On Tue, Feb 15, 2022 at 3:47 PM Jonas @.***> wrote:

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!

— Reply to this email directly, view it on GitHub https://github.com/jonaskuske/smoothscroll-anchor-polyfill/issues/34#issuecomment-1040776709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPZ32FIBTLSTI6JHGRD343U3K3U5ANCNFSM4K5R5XGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

DavidLindsey0118 avatar Feb 15 '22 21:02 DavidLindsey0118

To clarify, I'm only seeing this particular issue with the lib on IOS devices.

On Tue, Feb 15, 2022 at 4:03 PM David Lindsey @.***> wrote:

That would be incredible, thank you!

On Tue, Feb 15, 2022 at 3:47 PM Jonas @.***> wrote:

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!

— Reply to this email directly, view it on GitHub https://github.com/jonaskuske/smoothscroll-anchor-polyfill/issues/34#issuecomment-1040776709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPZ32FIBTLSTI6JHGRD343U3K3U5ANCNFSM4K5R5XGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

DavidLindsey0118 avatar Feb 15 '22 21:02 DavidLindsey0118

Nothing new for scroll-padding, BUT scroll-margin is supported when this lib is used in tandem with seamless-scroll-polyfill: https://github.com/jonaskuske/smoothscroll-anchor-polyfill/issues/51#issuecomment-1063970586

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

jonaskuske avatar Mar 12 '22 01:03 jonaskuske

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

DavidLindsey0118 avatar Mar 14 '22 18:03 DavidLindsey0118

@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: https://github.com/jonaskuske/smoothscroll-anchor-polyfill/issues/51#issuecomment-1063970586

jonaskuske avatar Mar 15 '22 01:03 jonaskuske

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!

DavidLindsey0118 avatar Mar 15 '22 16:03 DavidLindsey0118