magic-akari / seamless-scroll-polyfill

Scroll Behavior polyfill
https://www.npmjs.com/package/seamless-scroll-polyfill
MIT License
159 stars 11 forks source link

offset #83

Closed 719media closed 4 years ago

719media commented 4 years ago

This is a great library, thank you for sharing it.

FEATURE REQUEST: I wish there was a way to provide an offset parameter to the scrollIntoView. I realize this isn't part of the working draft (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView), so I understand not wanting to conflate the library. It's just the only thing that is holding me back from using this library for all of my smooth scrolling needs.

I'm using smooth scrolling, so merely offsetting the scroll as a separate option doesn't work for my use case.

Thank you for any thoughts you may have.

popbee commented 4 years ago

Maybe what you are looking for is support for "scroll-margin" CSS ?

https://stackoverflow.com/questions/49859042/scrollintoview-with-margin

719media commented 4 years ago

Not really, scroll-margin deals with scroll-snap. I just want a plain old offset. Anyway, after considering the various ways to solve this problem (scrolling to an element just relative or absolute positioned according to the offset, or getting the position from javascript and scrolling directly to the value instead of the position), I'm just going to close this.

TLDR: there are ways to accomplish this that are quite straightforward, not worth bloating the library, especially with non-standard parameters