0

I'm using the following call to scroll an element into view in Chrome:

element.scrollIntoView({
  block: 'center',
  inline: 'nearest
})

It works properly in Chrome, but in Safari and IE/Edge, it always scrolls as if I've used block: 'start'. Even when I try changing to block: 'end', it still scrolls that element to the top of its scrollable container.

Am I missing something?

See test code here: https://www.w3schools.com/code/tryit.asp?filename=G1V3LQQSAKF3 (sorry it's not a plunkr, but I copied the sample from the MDN site)

robert.bo.roth
  • 1,343
  • 3
  • 14
  • 24
  • According to https://caniuse.com/#feat=scrollintoview , it seems that Safari and Edge "Supports scrollIntoView with boolean parameter, but not smooth behavior option". Nice. – robert.bo.roth Mar 08 '19 at 00:22
  • I know the question there was about `Window.scrollTo`, while yours is about `Element.scrollIntoView` but really, it's just the same and the two top answers [1](https://stackoverflow.com/a/52277287/3702797) [2](https://stackoverflow.com/a/53672870/3702797) will help you workaround the issue. – Kaiido Mar 08 '19 at 01:47

0 Answers0