react-native-keyboard-controller
Version:
Keyboard manager which works in identical way on both iOS and Android
46 lines (44 loc) • 1.59 kB
JavaScript
import { useEvent, useHandler } from "react-native-reanimated";
export const useAnimatedKeyboardHandler = (handlers, dependencies) => {
const {
context,
doDependenciesDiffer
} = useHandler(handlers, dependencies);
return useEvent(event => {
"worklet";
const {
onKeyboardMoveStart,
onKeyboardMove,
onKeyboardMoveEnd,
onKeyboardMoveInteractive
} = handlers;
if (onKeyboardMoveStart && event.eventName.endsWith("onKeyboardMoveStart")) {
onKeyboardMoveStart(event, context);
}
if (onKeyboardMove && event.eventName.endsWith("onKeyboardMove")) {
onKeyboardMove(event, context);
}
if (onKeyboardMoveEnd && event.eventName.endsWith("onKeyboardMoveEnd")) {
onKeyboardMoveEnd(event, context);
}
if (onKeyboardMoveInteractive && event.eventName.endsWith("onKeyboardMoveInteractive")) {
onKeyboardMoveInteractive(event, context);
}
}, ["onKeyboardMoveStart", "onKeyboardMove", "onKeyboardMoveEnd", "onKeyboardMoveInteractive"], doDependenciesDiffer);
};
export const useFocusedInputLayoutHandler = (handlers, dependencies) => {
const {
context,
doDependenciesDiffer
} = useHandler(handlers, dependencies);
return useEvent(event => {
"worklet";
const {
onFocusedInputLayoutChanged
} = handlers;
if (onFocusedInputLayoutChanged && event.eventName.endsWith("onFocusedInputLayoutChanged")) {
onFocusedInputLayoutChanged(event, context);
}
}, ["onFocusedInputLayoutChanged"], doDependenciesDiffer);
};
//# sourceMappingURL=reanimated.native.js.map