Skip to content

Commit 0048264

Browse files
committed
fix(flick): fix issue where flick on first render
1 parent 8b022f0 commit 0048264

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ yarn install @appandflow/rn-magic-scroll
1010
npm i @appandflow/rn-magic-scroll
1111
```
1212

13+
### Android
14+
15+
On Android, make sure to set `android:windowSoftInputMode` in your `AndroidManifest.xml` to **pan**
16+
17+
##### Expo
18+
19+
```json
20+
// app.json
21+
"android": {
22+
...rest,
23+
"softwareKeyboardLayoutMode": "pan"
24+
}
25+
```
26+
1327
## Basic Usage
1428

1529
Wrap your form/screen within our ScrollView. Utilizing context requires it to be one level higher for enhanced control over your inputs. Alternatively, you can employ the Higher Order Component (HOC) for this purpose.

example/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"adaptiveIcon": {
2222
"foregroundImage": "./assets/adaptive-icon.png",
2323
"backgroundColor": "#ffffff"
24-
}
24+
},
25+
"softwareKeyboardLayoutMode": "pan"
2526
},
2627
"web": {
2728
"favicon": "./assets/favicon.png"

example/src/third-party/gorhom-bottom-sheet/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ const Form = () => {
1919
contentContainerStyle: {
2020
paddingHorizontal: 16,
2121
paddingBottom: insets.bottom + 20,
22-
backgroundColor: 'red',
2322
paddingTop: 100,
2423
},
25-
style: { backgroundColor: 'blue' },
2624
}}
2725
>
2826
<MagicScroll.TextInput

src/Provider.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React, {
77
import Animated, {
88
scrollTo,
99
useAnimatedRef,
10-
useAnimatedScrollHandler,
1110
useAnimatedStyle,
1211
useDerivedValue,
1312
useSharedValue,
@@ -83,12 +82,12 @@ export function ScrollView(
8382
additionalPadding?: number;
8483
}>
8584
) {
86-
const { scrollHandler, scrollRef, baseScrollViewProps, translateStyle } =
87-
useFormSmartScroll({ padding: props?.additionalPadding });
85+
const { scrollRef, baseScrollViewProps, translateStyle } = useFormSmartScroll(
86+
{ padding: props?.additionalPadding }
87+
);
8888

8989
return (
9090
<Animated.ScrollView
91-
onScroll={scrollHandler}
9291
ref={scrollRef}
9392
{...baseScrollViewProps}
9493
{...props.scollViewProps}
@@ -115,12 +114,6 @@ export function useFormSmartScroll({
115114

116115
const _keyboard = useKeyboard();
117116

118-
const scrollHandler = useAnimatedScrollHandler({
119-
onScroll: (event) => {
120-
scrollY.value = event.contentOffset.y;
121-
},
122-
});
123-
124117
const setState = useSetAtom(elementsAtom);
125118
const [inputs, setInputs] = useAtom(inputsAtom);
126119

@@ -189,7 +182,7 @@ export function useFormSmartScroll({
189182
);
190183

191184
useDerivedValue(() => {
192-
scrollTo(scrollRef, 0, scrollY.value, true);
185+
scrollTo(scrollRef, 0, scrollY.value, false);
193186
});
194187

195188
const onFocus = useCallback(
@@ -265,7 +258,6 @@ export function useFormSmartScroll({
265258
registerInput,
266259
chainInput,
267260
translateStyle,
268-
scrollHandler,
269261
scrollRef,
270262
baseScrollViewProps,
271263
baseTextInputProps,

0 commit comments

Comments
 (0)