ruotalogo.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function menu_get() {
  2. return document.querySelector('#menu-row')
  3. }
  4. function menu_is_shown() {
  5. return (window.getComputedStyle(menu_get()).display !== 'none')
  6. }
  7. function menu_hide() {
  8. menu_get().style.display = 'none'
  9. document.querySelector('#overlay').style.height = '0'
  10. }
  11. function menu_show() {
  12. menu_get().style.display = 'block'
  13. document.querySelector('#overlay').style.height = '100%'
  14. }
  15. document.addEventListener('DOMContentLoaded', function() {
  16. var logo = document.getElementById('logo-img')
  17. logo.classList.add('rotate')
  18. function ruotaLogo() {
  19. logo.style.transform = 'rotate(' + -window.pageYOffset/2+'deg)'
  20. }
  21. function scrollSetup() {
  22. "use strict";
  23. var last_known_scroll_position = 0
  24. var ticking = false
  25. window.addEventListener('scroll', function (e) {
  26. last_known_scroll_position = window.scrollY
  27. if (!ticking) {
  28. window.requestAnimationFrame(function () {
  29. ruotaLogo()
  30. ticking = false;
  31. });
  32. ticking = true;
  33. }
  34. })
  35. }
  36. setTimeout(function () {
  37. logo.classList.remove('rotate')
  38. scrollSetup()
  39. }, 1000)
  40. logo.addEventListener('click', function (evt) {
  41. if (!menu_is_shown()) {
  42. menu_show()
  43. } else {
  44. menu_hide()
  45. }
  46. })
  47. document.querySelector('#overlay').addEventListener('click', function (evt) {
  48. menu_hide()
  49. })
  50. })