Skip to content

Instantly share code, notes, and snippets.

@biswajitpaul01
Created August 9, 2019 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biswajitpaul01/3346619676a50d5d76e2c854fdc51ee2 to your computer and use it in GitHub Desktop.
Save biswajitpaul01/3346619676a50d5d76e2c854fdc51ee2 to your computer and use it in GitHub Desktop.
Using scrollIntoView() to show added elements to a container with overflow
/* list of characters */
let count = 0;
document.querySelector('button').addEventListener('click', (ev) => {
if (count < characters.length) {
let item = document.createElement('li');
item.innerText = characters[count];
document.querySelector('ul').appendChild(item);
item.scrollIntoView({behavior: 'smooth'});
count = count + 1;
}
ev.preventDefault;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment