sito-hackit-20/themes/maya0x17/static/ruotalogo.js
boyska 29aed3d534 logo ruota piu naturale
al contrario e piu lentamente
2020-07-28 02:39:53 +02:00

42 lines
1.2 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
console.log('start!')
var logo = document.getElementById('logo-img')
function ruotaLogo() {
logo.style.transform = 'rotate(' + -window.pageYOffset/2+'deg)'
}
function scrollSetup() {
"use strict";
let last_known_scroll_position = 0;
let ticking = false;
function doSomething(scroll_pos) {
// Do something with the scroll position
}
window.addEventListener('scroll', function(e) {
last_known_scroll_position = window.scrollY;
if (!ticking) {
window.requestAnimationFrame(function() {
ruotaLogo()
ticking = false;
});
ticking = true;
}
});
}
ruotaLogo()
scrollSetup()
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')
})
})