Reputation: 247
I have this scrollable div and inside i have an SVG with points that has id's given. i want to align the selected point to the centre of the div and i have this solution
document.getElementById("myID").scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'center'
})
this works fine in chrome but in safari it's not working, what is the best solution ?
Upvotes: 15
Views: 20467
Reputation: 87
scrollIntoView does not work if you are calling it inside an iframe element using an IOS device. But you can use parent.window.postMessage() and use scrollIntoView() there. You can also use window.scroll(), window.scrollTo(), window.scrollBy() and window scroll function available in javascript.
Upvotes: 0
Reputation: 6088
This is not supported in Safari. Specifically, scrollIntoViewOptions
is not supported, so you'll need to find a polyfill for this or employ another method entirely.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
Upvotes: 13