Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
How can I scrollIntoView/focus without the smooth scrolling animation? like focusing instantly on an element

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
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!