File tree Expand file tree Collapse file tree
src/components/KeyboardAwareScrollView Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import Reanimated, {
1616 useSharedValue ,
1717} from "react-native-reanimated" ;
1818
19+ import { KeyboardControllerNative } from "../../bindings" ;
1920import {
2021 useFocusedInputHandler ,
2122 useReanimatedFocusedInput ,
@@ -155,15 +156,20 @@ const KeyboardAwareScrollView = forwardRef<
155156 const { height } = useWindowDimensions ( ) ;
156157
157158 const onScrollViewLayout = useCallback (
158- ( e : LayoutChangeEvent ) => {
159- scrollViewTarget . value = findNodeHandle ( scrollViewAnimatedRef . current ) ;
159+ async ( e : LayoutChangeEvent ) => {
160+ const handle = findNodeHandle ( scrollViewAnimatedRef . current ) ;
160161
161- // @ts -expect-error something is wrong with the type of `measureInWindow`
162- scrollViewRef . current ?. measureInWindow ( ( _x , y ) => {
163- scrollViewPageY . value = y ;
164- } ) ;
162+ scrollViewTarget . value = handle ;
165163
166164 onLayout ?.( e ) ;
165+
166+ if ( handle !== null ) {
167+ const { y } = await KeyboardControllerNative . viewPositionInWindow (
168+ handle ,
169+ ) ;
170+
171+ scrollViewPageY . value = y ;
172+ }
167173 } ,
168174 [ onLayout ] ,
169175 ) ;
You can’t perform that action at this time.
0 commit comments