Created
August 9, 2019 17:26
-
-
Save biswajitpaul01/3346619676a50d5d76e2c854fdc51ee2 to your computer and use it in GitHub Desktop.
Using scrollIntoView() to show added elements to a container with overflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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