iamdustan / smoothscroll

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

Make scrollIntoView work for Safari and SVGElement #153

Open arambert opened 4 years ago

arambert commented 4 years ago

The polyfill for scrollIntoView doesn't work if you want to use it on an SVGElement (g, circle polygon, etc.) on Safari. On Safari SVGElement does not inherit from HtmlElement || Element. To make it work, after:

import smoothscroll from 'smoothscroll-polyfill' smoothscroll.polyfill() add:

window.SVGElement.prototype.scrollIntoView = (window.HTMLElement || window.Element).prototype.scrollIntoView

arambert commented 4 years ago

If you don't use {behavior: 'smooth'} in your arguments it won't work either.

arambert commented 4 years ago

I'd recommend using https://github.com/magic-akari/seamless-scroll-polyfill 👍 instead of this plugin.

ieozt38 commented 4 years ago

I'd recommend using https://github.com/magic-akari/seamless-scroll-polyfill 👍 instead of this plugin.

Thank you fixed my issue! 👍

acontreras89 commented 3 years ago

It is possible that this could be fixed by changing this line for

var Element = w.Element;