sito-hackit-20/themes/maya0x17/static/ruotalogo.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

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