fix: ignore non-keyboard animations #300
Merged
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
Check that current animation is a keyboard one. If not, then do not send any events to JS.
💡 Motivation and Context
Since we add generic
WindowInsetsAnimationCompat.Callback
-> its callbacks (onStart
/onProgress
/onEnd
) can be called even when keyboard is not performing an animation. Thus it's important to filter out which events are keyboard-related and which one are not.Initially I copied an example from Google samples, but their example code didn't have these checks. I assume it's because they had only one screen and it wasn't possible to run other insets animation.
However in Android documentation in code sample they added a check to filter out non-keyboard animations. So taking all the information from above I decided to add these checks and add early return statements to react only on keyboard animation events.
The similar approach was added in next projects:
📢 Changelog
Android
WindowInsetsAnimationCompat
extension (newisKeyboardAnimation
field);onStart
/onProgress
/onEnd
callbacks if provided animation is not keyboard animation.🤔 How Has This Been Tested?
Tested on:
📸 Screenshots (if appropriate):
No visual difference 🤷♂️
📝 Checklist