()
| 74 | // The duration has to be continuous, so losing the ratio or the tab focus |
| 75 | // drops the accumulated time instead of pausing it. |
| 76 | const evaluate = () => { |
| 77 | if (!criteria || !meetsRatio || !isPageInFocus()) { |
| 78 | stopTimer(); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | if (timeout) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | const met = criteria; |
| 87 | timeout = setTimeout(() => reportViewable(met), met.duration); |
| 88 | }; |
| 89 | |
| 90 | const observer = new IntersectionObserver( |
| 91 | (entries) => { |
no test coverage detected