()
| 86 | let pendingTimeout = null; |
| 87 | |
| 88 | const tick = () => { |
| 89 | if (!isUndefined(lastDuration) && lastDuration > 16) { |
| 90 | // We voluntarily throttle ourselves if we can't manage 60fps |
| 91 | lastDuration = Math.min(lastDuration - 16, 250); |
| 92 | |
| 93 | // Just in case this is the last event, remember to position just once more |
| 94 | pendingTimeout = setTimeout(tick, 250); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | if (!isUndefined(lastCall) && now() - lastCall < 10) { |
| 99 | // Some browsers call events a little too frequently, refuse to run more than is reasonable |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | if (pendingTimeout != null) { |
| 104 | clearTimeout(pendingTimeout); |
| 105 | pendingTimeout = null; |
| 106 | } |
| 107 | |
| 108 | lastCall = now(); |
| 109 | position(); |
| 110 | lastDuration = now() - lastCall; |
| 111 | }; |
| 112 | |
| 113 | if (typeof window !== 'undefined' && !isUndefined(window.addEventListener)) { |
| 114 | ['resize', 'scroll', 'touchmove'].forEach((event) => { |
nothing calls this directly
no test coverage detected
searching dependent graphs…