fix(anim): prevent swipe back animation getting stuck / not completing #23128
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.
closes #22895
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #22895
While debugging the swipe back gesture I noticed that there are some race conditions where the animation is never stopped. The endlessly running animation blocks all further animations/routing of the entire app (e.g. back-button, tabs, ...).
This happens when the swipe back gesture is performed very fast (not fast in the sense of quickly performing the gesture multiple times like in issue #15154, but instead only performing it once which a fast finger movement). This can especially be reproduced in about 50% of cases when trying to perform the gesture with as little time and horizontal movement of your finger as possible on the far left side of the page/device.
Debugging actually shows, that the gesture ends (
onEndHandler
called inswipe-back.ts
) BEFORE the animation actually started and the reference to the animationani
inroute-outlet.tsx
is set. Since the animation is progress-based and is only ever stopped by callingprogressEnd
, this leads to the endlessly running animation.What is the new behavior?
The supplied fix handles this edge case where the swipe gesture should be stopped, but the animation reference is not yet set. In that case the result params are temporary stored within the route-outlet and as soon as the animation reference is set, the animation will be stopped gracefully.
Does this introduce a breaking change?
Other information
I have tested it in our apps in combination with PR #23125 and its working very well. The app always stays responsive and routing always works even after performing the wildest swipe animations.