iamdustan / smoothscroll

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

scrollIntoView with arguments is not working #176

Open joyblanks opened 3 years ago

joyblanks commented 3 years ago

I have an element to center align in page respect to its parent

document.querySelector('#someid').scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' });

It works fine without this polyfill (but without behavior smooth of course), But when the polyfill is active the arguments are discarded

isGabe commented 3 years ago

Same issue here, trying to get it working in React + iOS Safari, but it's leading me to believe that the polyfill just isn't loading at all, since Safari does support scrollIntoView() without options;

I've looked through #139 and tried all different combinations of importing, putting in a useEffect hook moving it to the top level index.tsx component, etc, and it just won't work if I add options.

isGabe commented 3 years ago

Well, I figured out why it wasn't working in my case. For reasons that aren't relevant here, I had this in my css:

html,
body {
  height: 100%;
  overflow: auto;
  width: 100%;
}

Removing overflow: auto made the scrolling work. Now I have to do some work to be able to remove that style without breaking something else. Ah, web development 🙂

kunal-compro commented 2 years ago

Well, I figured out why it wasn't working in my case. For reasons that aren't relevant here, I had this in my css:

html,
body {
  height: 100%;
  overflow: auto;
  width: 100%;
}

Removing overflow: auto made the scrolling work. Now I have to do some work to be able to remove that style without breaking something else. Ah, web development 🙂

Removing overflow: auto from parent worked for me too. Not sure why it worked🤨