I have a vertically long SVG image that I need to scroll to some specific element with a specific id.
const el = document.getElementById(id);
el.scrollIntoView({
behavior: 'smooth',
block: 'center'
});
This works fine in chrome but Firefox scrolls into view the top of the SVG file, not the selected element.
I reproduced the bug in a stackblitz:
https://stackblitz.com/edit/react-wkoiwq
https://react-wkoiwq.stackblitz.io
In chrome the #hotplate element is moved to the center while in firefox the top of the SVG is moved to the center.
Try changing center
, with start
and end
to see the effect.
Is there a way to fix / avoid this problem?