()
| 188 | } |
| 189 | |
| 190 | function trackScroll() { |
| 191 | // Throttle the calculations to no more than five per second |
| 192 | if (pauseScrolling) return |
| 193 | pauseScrolling = true |
| 194 | setTimeout(() => { |
| 195 | pauseScrolling = false |
| 196 | }, 200) |
| 197 | |
| 198 | // Calculate where we are on the page |
| 199 | const scrollPixels = window.scrollY + window.innerHeight |
| 200 | const newScrollPosition = scrollPixels / document.documentElement.scrollHeight |
| 201 | |
| 202 | // Count scroll flips |
| 203 | const newScrollDirection = Math.sign(newScrollPosition - scrollPosition) |
| 204 | if (newScrollDirection !== scrollDirection) scrollFlipCount++ |
| 205 | |
| 206 | // Update maximum scroll position reached |
| 207 | if (newScrollPosition > maxScrollY) maxScrollY = newScrollPosition |
| 208 | |
| 209 | // Update before the next event |
| 210 | scrollDirection = newScrollDirection |
| 211 | scrollPosition = newScrollPosition |
| 212 | } |
| 213 | |
| 214 | function sendPage() { |
| 215 | const pageEvent = sendEvent({ type: EventType.page }) |
nothing calls this directly
no outgoing calls
no test coverage detected