iamdustan / smoothscroll

Scroll Behavior polyfill
http://iamdustan.com/smoothscroll/
MIT License
3.85k stars 339 forks source link

[Feature Request] Padding option #155

Closed davestewart closed 4 years ago

davestewart commented 4 years ago

It would be great if you could specify some padding for items when scrolled into view so they don't appear stuck to the edge of the viewport:

document
  .querySelector('.hello')
  .scrollIntoView({ behavior: 'smooth', padding: 20 });
iamdustan commented 4 years ago

Hey @davestewart,

This project is only meant to polyfill behavior that is in spec and not be a general purpose scrolling library. If that is added to the spec then we could definitely take it on.

davestewart commented 4 years ago

Hey, thanks for the reply!

In the meantime I wrote my own code for getting regions, adding padding, determining offset then scrollBy(x, y) using this lib.

Thank you!