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

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-08-05 14:28:25 +02:00
function menu_get() {
return document.querySelector('#menu-row')
}
function menu_is_shown() {
return (window.getComputedStyle(menu_get()).display !== 'none')
}
function menu_hide() {
menu_get().style.display = 'none'
2020-08-05 14:39:24 +02:00
document.querySelector('#overlay').style.height = '0'
2020-08-05 14:28:25 +02:00
}
function menu_show() {
menu_get().style.display = 'block'
2020-08-05 14:39:24 +02:00
document.querySelector('#overlay').style.height = '100%'
2020-08-05 14:28:25 +02:00
}
2020-07-28 02:33:53 +02:00
document.addEventListener('DOMContentLoaded', function() {
2020-08-05 14:28:25 +02:00
var logo = document.getElementById('logo-img')
logo.classList.add('rotate')
function ruotaLogo() {
2020-08-06 00:38:38 +02:00
logo.style.transform = 'rotate(' + -window.pageYOffset/2+'deg)'
2020-08-05 14:28:25 +02:00
}
function scrollSetup() {
"use strict";
var last_known_scroll_position = 0
var ticking = false
2020-07-28 02:33:53 +02:00
2020-08-05 14:28:25 +02:00
window.addEventListener('scroll', function (e) {
last_known_scroll_position = window.scrollY
2020-07-28 02:33:53 +02:00
2020-08-05 14:28:25 +02:00
if (!ticking) {
window.requestAnimationFrame(function () {
2020-07-28 02:33:53 +02:00
2020-08-05 14:28:25 +02:00
ruotaLogo()
ticking = false;
});
2020-07-28 02:33:53 +02:00
2020-08-05 14:28:25 +02:00
ticking = true;
}
2020-07-28 02:33:53 +02:00
})
2020-08-05 14:28:25 +02:00
}
setTimeout(function () {
logo.classList.remove('rotate')
scrollSetup()
}, 1000)
logo.addEventListener('click', function (evt) {
if (!menu_is_shown()) {
menu_show()
} else {
menu_hide()
}
})
2020-08-05 14:39:24 +02:00
document.querySelector('#overlay').addEventListener('click', function (evt) {
2020-08-05 14:28:25 +02:00
menu_hide()
})
2020-07-28 02:33:53 +02:00
})