Properly minify CSS but now also Javascript.
This commit is contained in:
parent
fda8fd4e00
commit
6ef8329fdf
6 changed files with 200 additions and 14 deletions
|
|
@ -1,53 +0,0 @@
|
|||
/**
|
||||
* @type {NodeListOf<HTMLVideoElement>}
|
||||
*/
|
||||
const parallaxElems = document.querySelectorAll('.parallax');
|
||||
|
||||
/**
|
||||
* @type {NodeListOf<HTMLElement>}
|
||||
*/
|
||||
const sections = document.querySelectorAll('.section');
|
||||
|
||||
// Handle scroll events.
|
||||
window.addEventListener('scroll', () =>
|
||||
{
|
||||
// Add class to body when scrolled.
|
||||
document.body.classList.toggle('is-scrolled', window.scrollY > 0);
|
||||
|
||||
// Parallax effect.
|
||||
parallaxElems.forEach(parallaxElem =>
|
||||
{
|
||||
const parentElem = parallaxElem.parentElement;
|
||||
|
||||
const parentRect = parentElem.getBoundingClientRect();
|
||||
const parentScroll = parentRect.top + (parentRect.height / 2);
|
||||
|
||||
const windowScroll = window.scrollY + (window.innerHeight / 2);
|
||||
|
||||
parallaxElem.style.top = `${(windowScroll - parentScroll) / 4}px`;
|
||||
});
|
||||
});
|
||||
|
||||
sections.forEach(section =>
|
||||
{
|
||||
if (section.id)
|
||||
{
|
||||
const anchor = document.createElement('a');
|
||||
anchor.className = 'anchor-link';
|
||||
anchor.href = `#${section.id}`;
|
||||
anchor.innerHTML = ' # ';
|
||||
section.appendChild(anchor);
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('#navbarNav li.nav-item>a').forEach(anchor =>
|
||||
{
|
||||
anchor.addEventListener('click', () =>
|
||||
{
|
||||
/**
|
||||
* @type {HTMLButtonElement}
|
||||
*/
|
||||
const navbarNav = document.querySelector('button.navbar-toggler[aria-expanded="true"]');
|
||||
navbarNav?.click();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue