• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #13225

pending completion
#13225

push

circleci

web-flow
chore: Remove optional Chaining

Co-authored-by: Vincent <Vinnl@users.noreply.github.com>

282 of 1677 branches covered (16.82%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

959 of 4545 relevant lines covered (21.1%)

1.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/client/js/section-observer.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
const classNameToObserve = 'section-transition'
×
6
const classNameEntered = `${classNameToObserve}-entered`
×
7
const cueIntervalDuration = 150
×
8
const sectionThreshold = 0.1
×
9

10
let observers
11
let cueInterval
12
const entryCue = []
×
13

14
function handleShowSection () {
15
  if (!entryCue.length && cueInterval) {
×
16
    clearInterval(cueInterval)
×
17
    cueInterval = null
×
18
    return
×
19
  }
20

21
  const nextEntry = entryCue.shift()
×
22
  nextEntry.target.classList.add(classNameEntered)
×
23
}
24

25
function setCueInterval () {
26
  cueInterval = setInterval(handleShowSection, cueIntervalDuration)
×
27
}
28

29
function handleScroll (entries) {
30
  entries.forEach(entry => {
×
31
    const sectionElement = entry.target
×
32
    const hasEntered = sectionElement.classList.contains(classNameEntered)
×
33

34
    if (hasEntered) {
×
35
      return
×
36
    }
37

38
    const isInViewport = entry.isIntersecting
×
39
    if (isInViewport) {
×
40
      entryCue.push(entry)
×
41
    }
42

43
    if (!cueInterval) {
×
44
      setCueInterval()
×
45
    }
46
  })
47
}
48

49
function init (sections) {
50
  const observer = new IntersectionObserver(handleScroll, {
×
51
    threshold: sectionThreshold
52
  })
53

54
  observers = [...sections].map(section => {
×
55
    observer.observe(section)
×
56
    return observer
×
57
  })
58

59
  setCueInterval()
×
60
}
61

62
if (!observers) {
×
63
  const mediaQuery = window.matchMedia('(prefers-reduced-motion: no-preference)')
×
64
  const allowMotion = mediaQuery && mediaQuery.matches
×
65

66
  const sections = document.getElementsByClassName(classNameToObserve)
×
67
  mediaQuery.addEventListener('change', () => {
×
68
    [...sections].forEach(section => section.classList.add(classNameEntered))
×
69
  })
70

71
  if (allowMotion) {
×
72
    init(sections)
×
73
  }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc