Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function scrollToHash(hash, wait = true) {
const elem = hash && hash.indexOf("#") === 0 ? document.getElementById(hash.slice(1)) : false;
if (elem) {
const offset = elem.getBoundingClientRect().top;
if (offset) {
animateScroll.scrollMore(offset);
setTimeout(() => {
elem.focus();
}, 100);
}
}
else if (wait) {
setTimeout(() => {
scrollToHash(hash, false);
}, 100);
}
}
<li> <a> animateScroll.scrollMore(500)}>Scroll 500 More!</a></li>
<li> <a> animateScroll.scrollMore(1000, { delay : 1500 })}>Scroll 1000 More! ( delay ) </a></li>
<li> <a> animateScroll.scrollMore(1000, { delay : 1500 })}>Scroll 1000 More! ( delay ) </a></li>
<li>Same target</li>