www.netz39.de/assets/js/partials/navbar.js

27 lines
759 B
JavaScript
Raw Normal View History

2023-10-16 01:36:59 +02:00
/* @preserve Navbar */
document.addEventListener("DOMContentLoaded", function (event) {
/*
* Display the menu items on smaller screens
*/
const pull = document.getElementById('pull');
const menu = document.querySelector('nav ul');
['click', 'touch'].forEach(function (e) {
pull?.addEventListener(e, function () {
menu.classList.toggle('hide')
}, false);
});
/*
* Make the header images move on scroll
*/
window.addEventListener('scroll', function () {
const offset = -(window.scrollY || window.pageYOffset || document.body.scrollTop) / 3;
const main = document.getElementById('main');
if (main) {
main.style.backgroundPosition = '100% ' + (offset - 50) + 'px' + ', 0%, center top';
}
});
});