aboutsummaryrefslogtreecommitdiff
path: root/public/js/demos/hover.js
blob: 57d9f3c273b7a61282b9fd9d78ef5709abdc86ab (plain) (blame)
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
var highlightIntervals = [
  {
    on: [550, 3900],
    off: [1400, 4150],
  },
  {
    on: [1700, 3500],
    off: [1900, 3800],
  },
  {
    on: [2000],
    off: [3400],
  },
]

function highlightSequence() {
  var examples = [].slice.call(
    document.querySelectorAll(".hover-a11y:not(.no-active)")
  )

  examples.forEach(function(example) {
    console.log(example)
    var links = [].slice.call(example.querySelectorAll(".button"))

    highlightIntervals.forEach(function(timers, i) {
      timers.on.forEach(function(ms) {
        setTimeout(function() {
          links[i].classList.add("active")
        }, ms)
      })

      timers.off.forEach(function(ms) {
        setTimeout(function() {
          links[i].classList.remove("active")
        }, ms)
      })
    })
  })
}

setInterval(highlightSequence, 6000)
highlightSequence() // call once to start