New issue
Advanced search Search tips

Issue 923739 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

scrollIntoView({behavior:'smooth'}) doens't work if called rapidly.

Project Member Reported by ojan@chromium.org, Jan 20 (2 days ago)

Issue description

See test case below. This is a reduced test case of a real problem on my site. Happy to share the site privately if it's helpful. My site uses keyboard shortcuts to scroll between items. If you hold down the key, it fires very rapily and does what the fiddle below does.

If you change the interval timer below to 1000, then it all works as expected. If you make it 100, then it kinda works, but in a clearly broken way. If you set it to 10, then the page doesn't scroll at all until you stop the timer.

I doubt this is platform specific, but in case it is, I'm on ChromeOS.

Possibly related to issue 833617.

https://jsfiddle.net/yj24Lust/

for (let i = 0; i < 1000; i++) {
  let child = document.createElement('div');
  child.id = `id-${i}`;
  child.textContent = i;
  child.style.cssText = `
    height: 100px;
    border: 2px solid;
    margin: 6px;
  `;
  document.body.append(child);
}

let i = 0;
setInterval(() => {
  i++;
  let next = document.getElementById(`id-${i}`);
  next.scrollIntoView({behavior:'smooth'});
}, 10);
 

Sign in to add a comment