fix: slow back transitions on Android < 11 in KeyboardAwareScrollView
#342
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Improved FPS for
KeyboardAwareScrollView
when keyboard gets closed (and scroll position is the end of the scroll view).💡 Motivation and Context
The fix consist of several stages. Below they are:
1️⃣ Incorrect
persistentHeight
updateWhen we reset
persistentHeight
inonEnd
we:persistentHeight
can be set to0
after timing animation completion and because of thatonEnd
handler may not be fired at all)progress
incorrectly (it can beInfinity
orNaN
in last frames of animation2️⃣ Avoid double
onMove
/onEnd
eventsIf we reset
persistentHeight
to0
inuseAnimatedReaction
(where we dispatchonEnd
) -> we run animation effect again, and it may produce additionalonMove
/onEnd
events afteronEnd
event. So I addedif (persistentHeight.value === 0)
check.3️⃣ Don't re-calculate layout in every animation frame
When we scroll to the end of ScrollView and change padding, it seems like we do a heavy layout re-calculation. That's why I added
+1
padding.Closes #335
📢 Changelog
JS
useSmoothKeyboardHandler
for Android < 10;🤔 How Has This Been Tested?
Tested manually on Xiaomi Redmi Note 5 Pro. Also I use 2500ms instead of 250ms timing to see more detailed difference.
📸 Screenshots (if appropriate):
useSmoothKeyboardHandler
+1
fixtelegram-cloud-document-2-5291837971429870538.mp4
telegram-cloud-document-2-5291837971429870537.mp4
telegram-cloud-document-2-5291837971429870536.mp4
📝 Checklist