Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.js « src « scripts « static - github.com/kdevo/osprey-delight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: acf7013efe34654064b346380b7a3669d297fd33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function() {
  var $ = document.querySelector.bind(document),
      $$ = document.querySelectorAll.bind(document),

      toggle = function(el) {
        // If element is visible, hide it
        if (window.getComputedStyle(el).visibility === 'visible') {
          el.style.visibility = 'hidden'
          el.classList.add('hide')
          el.classList.remove('show')
          return
        };

        // If element is hidden, show it
        el.style.visibility = 'visible'
        el.classList.add('show')
        el.classList.remove('hide')
      }

  // Nav is fixed to top
  $('nav').classList.add('nav-fixed')
  $$('nav > .logo, nav > .nav-toggle').forEach(function(el) {
    el.style.visibility = 'visible'
    el.classList.add('show')
    el.classList.remove('hide')
  })

  // Full screen nav open on click
  $('.nav-icon').addEventListener('click', function() {
    $$('.nav-full, main').forEach(function(el) {
      el.classList.toggle('active')
    })
    this.querySelector('img').classList.toggle('img')
  })

  // Full screen nav close on click
  $$('.nav-full a').forEach(function(links) {
    links.addEventListener('click', function() {
      $$('.nav-full, main').forEach(function(el) {
        el.classList.toggle('active')
      })
      this.querySelector('nav-icon').classList.toggle('nav-icon')
    })
  })

  // Disable scroll when full screen nav is open
  $('body').addEventListener('click', function() {
    if ($('.nav-full').classList.contains('active')) {
      $('html').style.overflowY = 'hidden'
    } else {
      $('html').style.overflowY = 'scroll'
    }
  })
})()