ScrollTo method doesn't work in Edge

Valerii Voronkov picture Valerii Voronkov · Jul 25, 2018 · Viewed 13.5k times · Source

I use scroll in my method

const scrollToCenter = () => {
 const kon = document.querySelector('.clazz');
 const width = kon.offsetWidth;
 kon.scrollTo(width / 2, 0);
 };

and it works fine in Chrome and Mozilla. In the Edge I'd got an error "Object doesn't support property or method scrollTo". Is exist any different method to use it in Edge?

Answer

Roberto Kedmenec picture Roberto Kedmenec · Jul 25, 2018

The official report : https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15534521/

The issue has been assigned to someone.

Following the comments the workaround is

" .scrollTop = 0 instead of .scrollTo(0,0) In case you want to scroll somewhere else than top i haven’t found a workaround "