File tree Expand file tree Collapse file tree 4 files changed +10426
-18397
lines changed Expand file tree Collapse file tree 4 files changed +10426
-18397
lines changed Original file line number Diff line number Diff line change 7171 "react-native" : " 0.73.6" ,
7272 "react-native-builder-bob" : " ^0.23.2" ,
7373 "react-native-reanimated" : " ^3.11.0" ,
74+ "react-native-safe-area-context" : " ^4.10.5" ,
7475 "release-it" : " ^15.0.0" ,
7576 "typescript" : " ^5.2.2"
7677 },
8081 "peerDependencies" : {
8182 "react" : " *" ,
8283 "react-native" : " *" ,
83- "react-native-reanimated" : " >=2.0.0"
84+ "react-native-reanimated" : " >=2.0.0" ,
85+ "react-native-safe-area-context" : " *"
8486 },
8587 "workspaces" : [
8688 " example"
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import {
3737 wrapperViewRefAtom ,
3838} from './state' ;
3939import { useKeyboard } from './useKeyboard' ;
40+ import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
4041
4142const isAndroid = Platform . OS === 'android' ;
4243
@@ -120,6 +121,7 @@ export function useFormSmartScroll({
120121} : {
121122 padding ?: number ;
122123} = { } ) {
124+ const insets = useSafeAreaInsets ( ) ;
123125 const wrapperOffset = useAtomValue ( wrapperOffsetAtom ) ;
124126 const scrollY = useSharedValue ( 0 ) ;
125127 const scrollRef = useAnimatedRef < Animated . ScrollView > ( ) ;
@@ -141,14 +143,15 @@ export function useFormSmartScroll({
141143 _keyboard . coordinates . end . screenY - currentFocus . height * 2
142144 ) {
143145 if ( wrapperOffset ) {
144- const diff = Math . abs (
145- _keyboard . coordinates . end . screenY -
146- currentFocus . position -
147- currentFocus . height -
148- padding +
149- scrollY . value -
150- wrapperOffset
151- ) ;
146+ const diff =
147+ Math . abs (
148+ _keyboard . coordinates . end . screenY -
149+ currentFocus . position -
150+ currentFocus . height -
151+ padding +
152+ scrollY . value -
153+ wrapperOffset
154+ ) + insets . top ;
152155 return - diff ;
153156 }
154157
You can’t perform that action at this time.
0 commit comments