I've tried setting behavior: 'instant' in the scrollIntoView options, but it didn't work, and also preventScroll: false for focus options, but it still scrolls smoothly to reach the element
on this page https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus in the last code snippet, it behaves like what I want, it instantly focuses on the element, without the scrolling animation, but for me, it always scrolls smoothly until it reaches the element, how can I disable that scrolling animation?
// Show next page
function showNextPage() {
let currPage = parseInt(pageCounter.textContent);
let target = document.querySelector(`[data-page="${currPage + 1}"]`);
target.focus({ preventScroll: false }); // DIDN"T WORK
}
// Show next page
function showNextPage() {
let currPage = parseInt(pageCounter.textContent);
let target = document.querySelector(`[data-page="${currPage + 1}"]`);
target.scrollIntoView({ behavior: 'instant' }); // DIDN"T WORK
}
scrollIntoView with no parameter should scroll instantly.
function showNextPage() {
let currPage = parseInt(pageCounter.textContent);
let target = document.querySelector(`[data-page="${currPage + 1}"]`);
target.scrollIntoView();
}
Also, you should remove scroll-behavior: smooth if you have any in your element's CSS. That could also cause smooth scrolling.