Skip to content
Advertisement

Mobile Safari, scrollIntoView doesn’t work

I have a problem with scroll to element on mobile Safari in iframe (it works on other browsers, including Safari on mac).

I use scrollIntoView. I want to scroll when all content has been rendered. Here is my code:

JavaScript

Advertisement

Answer

ScrollIntoView does not work (currently). But you can manually calculate the position of the element and scroll to it. Here is my solution

JavaScript

Pass the element to this function

JavaScript

Pitfalls: Smooth scroll also does not work for ios mobile, but you can complement this code with this polyfill

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement