sito-hackit-20/themes/maya0x17/static/ruotalogo.js
2020-07-28 17:29:25 +02:00

41 lines
1.2 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
var logo = document.getElementById('logo-img')
logo.classList.add('rotate')
function ruotaLogo() {
logo.style.transform = 'rotate(' + -window.pageYOffset/2+'deg)'
}
function scrollSetup() {
"use strict";
var last_known_scroll_position = 0
var ticking = false
window.addEventListener('scroll', function (e) {
last_known_scroll_position = window.scrollY
if (!ticking) {
window.requestAnimationFrame(function () {
ruotaLogo()
ticking = false;
});
ticking = true;
}
})
}
setTimeout(function () {
logo.classList.remove('rotate')
//ruotaLogo()
scrollSetup()
}, 1000)
logo.addEventListener('click', function () {
var menu = document.querySelector('#menu-row')
if (window.getComputedStyle(menu).display === 'none') {
menu.style.display = 'block'
// menu.scrollIntoView()
} else {
menu.style.display = 'none'
}
console.log('cliccato')
})
})