Updated web script
Used emoji for clipboard icons, added persistent scroll to top button with proper smooth scrolling.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<button class="scroll-to-top">↑</button>
|
||||
<footer>
|
||||
<p style="display: inline-block;"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br/>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/">CC 3.0 BY</a>.<br/>Ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> is licensed by <a href="https://opensource.org/licenses/MIT">The MIT License</a><br/>Built with the <a href="https://minicss.org">mini.css framework</a>.</p>
|
||||
<a href="#top"><span style="display: inline-block;float: right;padding-right: 2em;">Back to top</span></a>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@ -27,6 +27,13 @@
|
||||
x.style.display = matchingTags.includes(x.innerText.toLowerCase()) ? '' : 'none';
|
||||
})
|
||||
}
|
||||
function scrollToTop(){
|
||||
const c = document.querySelector('main').scrollTop;
|
||||
if (c > 0) {
|
||||
window.requestAnimationFrame(scrollToTop);
|
||||
document.querySelector('main').scrollTo(0, c - c / 4);
|
||||
}
|
||||
};
|
||||
function loader() {
|
||||
registerClickListener();
|
||||
}
|
||||
@ -54,6 +61,9 @@
|
||||
},300);
|
||||
},1700);
|
||||
}
|
||||
else if (event.target.classList.contains('scroll-to-top')){
|
||||
scrollToTop();
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user