react-native-avoid-softinput icon indicating copy to clipboard operation
react-native-avoid-softinput copied to clipboard

Animation feels like lagging With mimic IOS behavior and flickering when turned off

Open 25khattab opened this issue 2 years ago • 9 comments

Environment

Library version: 4.0.1 OS version: Pixel 7, android 13

Affected platforms

  • [X] Android
  • [ ] iOS

Current behavior

There is 2 problems first one with AvoidSoftInput.setShouldMimicIOSBehavior(true); The animation feels like lagging for some reason it works fine if the keyboard is under the input as it clear in the video, but it begins to lag when it pushes the view and I don't know why it doesn't animate correctly

https://github.com/mateusz1913/react-native-avoid-softinput/assets/53271078/69feacf2-698f-4962-b173-ba8ddc535ac2

when I remove the animation delay it flickers like mad man

https://github.com/mateusz1913/react-native-avoid-softinput/assets/53271078/f817d7b4-f1ad-4993-91e7-1c5008e0ffb2

Expected behavior

the animation should be smooth like the example app which is strange for some reason or maybe like whatsapp handles it.

https://github.com/mateusz1913/react-native-avoid-softinput/assets/53271078/b76d038c-8d40-49b6-9d0b-6b7a99da4934

Reproduction

https://github.com/25khattab/react-native-template

25khattab avatar Sep 16 '23 20:09 25khattab

@mateusz1913 sorry for many issues in that little time

25khattab avatar Sep 16 '23 20:09 25khattab

Regarding the first recording, I don't see any wrong behavior. When the first 2 inputs are focused, the padding is applied, but there's no need to change the scroll offset. For the 3rd input, there's a scroll by minimal offset 5/10px, because the keyboard top edge is covering that input only by a few pixels. The rest of inputs would be fully covered by the keyboard and the library is correctly scrolling them, so that they are displayed above the keyboard.

Regarding the second recording and comparing it to the Whatsapp - I assume that Whatsapp doesn't use edge-to-edge, instead relying on standard android:windowSoftInputMode="adjustResize" behavior. If that's what you would expect (so no animation), then you can just enable the library for iOS (AvoidSoftInput.setEnabled(Platform.OS === 'ios')) and leave the android handling to the default OS behavior (so not calling AvoidSoftInput.setShouldMimicIOSBehavior)

mateusz1913 avatar Sep 16 '23 20:09 mateusz1913

Ok i will test it but regarding the first video the last 2 inputs the animation when closing the keyboard isn't smooth at all

25khattab avatar Sep 16 '23 20:09 25khattab

If it's smooth in the example app and not smooth in your app, then I'd check either styles applied to the scroll view, or consider applying the padding manually - you can check the sticky footer example where the offset is applied to reanimated shared value and then the spacer view is animated - that may give better control over the animation

mateusz1913 avatar Sep 16 '23 20:09 mateusz1913

It's the same issue. Can't Android use this library?

dkahdwk avatar Sep 27 '23 06:09 dkahdwk

@dkahdwk what do you mean?

mateusz1913 avatar Sep 27 '23 07:09 mateusz1913

@dkahdwk what do you mean?

Same bug in android like @25khatab issue.

dkahdwk avatar Oct 04 '23 00:10 dkahdwk

just use react-native-keyboard-controller

fukemy avatar Oct 05 '23 15:10 fukemy

@25khattab , @mateusz1913 , @dkahdwk , I faced the same issue. Actually, this is not a bug. You have to tweak the values . In my case, I set the value as following.

AvoidSoftInput.setEnabled(true);
AvoidSoftInput.setShouldMimicIOSBehavior(true);
AvoidSoftInput.setHideAnimationDuration(100);
AvoidSoftInput.setShowAnimationDuration(100);

saadi-ninjasCode avatar Nov 08 '23 12:11 saadi-ninjasCode