thema de comienzo con efectos
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/* Top scroll progress from trivelta: the bar fills as the page scrolls. */
|
||||
(function () {
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'scroll-progress';
|
||||
bar.setAttribute('aria-hidden', 'true');
|
||||
document.body.appendChild(bar);
|
||||
|
||||
function onScroll() {
|
||||
var scrolled = window.scrollY || window.pageYOffset;
|
||||
var max = document.documentElement.scrollHeight - window.innerHeight;
|
||||
var progress = max > 0 ? Math.min(1, scrolled / max) : 0;
|
||||
|
||||
bar.style.transform = 'scaleX(' + progress + ')';
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
window.addEventListener('resize', onScroll);
|
||||
onScroll();
|
||||
}());
|
||||
Reference in New Issue
Block a user