Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollTo method doesn't work in Edge

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?

like image 720
Valerii Voronkov Avatar asked Jul 25 '18 11:07

Valerii Voronkov


1 Answers

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 "

like image 90
Roberto Kedmenec Avatar answered Oct 15 '22 11:10

Roberto Kedmenec