react-native-gesture-handler
Version:
Declarative API exposing native platform touch and gesture system to React Native
34 lines (31 loc) • 1.47 kB
JavaScript
;
import * as React from 'react';
import { TextInput } from 'react-native';
export const JSResponderContext = /*#__PURE__*/React.createContext(null);
export function updateResponderEventValue(jsResponderContext, value) {
const responderEventRef = jsResponderContext?.isRNGHResponderEvent;
if (responderEventRef) {
responderEventRef.current = value;
}
}
let isKeyboardVisible = false;
let keyboardOpenedForRNInput = false;
export function setKeyboardVisibility(visible) {
isKeyboardVisible = visible;
// Snapshotted at show-time: the dismissal blurs the input at touch-down,
// before the press events get checked
keyboardOpenedForRNInput = visible && TextInput.State.currentlyFocusedInput?.() != null;
}
export function isKeyboardDismissingTap(jsResponderContext) {
if (jsResponderContext == null) {
return false;
}
const mode = jsResponderContext.keyboardShouldPersistTaps;
const keyboardNeverPersistTaps = !mode || mode === 'never';
// Drop only taps that can dismiss the keyboard, i.e. an RN TextInput is (or
// was at show-time) focused - mirrors RN ScrollView's `_keyboardIsDismissible`.
// A native field's keyboard (e.g. a native-stack search bar) can't be
// blurred, so dropping there would leave presses permanently dead
return keyboardNeverPersistTaps && isKeyboardVisible && (keyboardOpenedForRNInput || TextInput.State.currentlyFocusedInput?.() != null);
}
//# sourceMappingURL=scrollViewInterop.js.map