Anyone know which is the differences between scrollIntoView() vs scrollIntoViewIfNeeded()?
I didn't see the differences between them. They both scroll if the element is not in visible area & do nothing if already visible.
If using the scrollIntoView() 'block' parameters 'start' (default), 'center' or 'end' scrollIntoView() always scrolls the element to the specified position even if it's already all on screen.
If using the parameter block: 'nearest' it behaves more like scrollIntoViewIfNeeded(), i.e. nothing happens if it is already on screen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With