MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onTransitionFrame

Function onTransitionFrame

packages/react-aria/src/utils/runAfterKeyboard.ts:29–61  ·  view source on GitHub ↗
(wasOpenKeyboard: boolean, signal: AbortSignal)

Source from the content-addressed store, hash-verified

27}
28
29function 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
63function setupGlobalListeners(timeout = TRANSITION_TIMEOUT): number {
64 return window.setInterval(

Callers

nothing calls this directly

Calls 4

isKeyboardOpenFunction · 0.90
setupGlobalListenersFunction · 0.85
deleteMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected