(wasOpenKeyboard: boolean, signal: AbortSignal)
| 27 | } |
| 28 | |
| 29 | function onTransitionFrame(wasOpenKeyboard: boolean, signal: AbortSignal): void { |
| 30 | let isOpenKeyboard = isKeyboardOpen(); |
| 31 | |
| 32 | // Flush resize callbacks when the keyboard has affected layout or we ran out of time. |
| 33 | if (wasOpenKeyboard !== isOpenKeyboard || signal.aborted) { |
| 34 | for (let callback of resizeCallbacks) { |
| 35 | callback(isOpenKeyboard); |
| 36 | resizeCallbacks.delete(callback); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // WebKit only fires a single resize event at the start of an opening transition. |
| 41 | // The animation takes ~200ms, so restart the listener and flush when it runs out of time. |
| 42 | if (!wasOpenKeyboard && isOpenKeyboard && isWebKit() && !signal.aborted) { |
| 43 | window.clearInterval(listenersByWindow.get(window)); |
| 44 | listenersByWindow.set(window, setupGlobalListeners(WEBKIT_OPEN_DELAY)); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | // Flush transition callbacks when the animation has completed or we ran out of time. |
| 49 | if (wasOpenKeyboard !== isOpenKeyboard || signal.aborted) { |
| 50 | for (let callback of transitionCallbacks) { |
| 51 | callback(isOpenKeyboard); |
| 52 | transitionCallbacks.delete(callback); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | // Cancel the observer when no pending updates remain or we ran out of time. |
| 57 | if (resizeCallbacks.size + transitionCallbacks.size <= 0 || signal.aborted) { |
| 58 | window.clearInterval(listenersByWindow.get(window)); |
| 59 | listenersByWindow.delete(window); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | function setupGlobalListeners(timeout = TRANSITION_TIMEOUT): number { |
| 64 | return window.setInterval( |
nothing calls this directly
no test coverage detected