-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(toast): add swipe gesture implementation #28402
Conversation
78d44a3
to
490d43d
Compare
Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, works great!
@@ -685,6 +685,7 @@ export const safeCall = (handler: any, arg?: any) => { | |||
|
|||
export const BACKDROP = 'backdrop'; | |||
export const GESTURE = 'gesture'; | |||
export const OVERLAY_GESTURE_PRIORITY = 39; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach - is the idea that future gesture priorities will be abstracted into this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it would makes sense to put all the gesture priorities in this file specifically, but I think long term it would be good to have them consolidated somewhere. Right now it's difficult to understand if changing a priority will cause other gestures used at the same time to break. Some of the gesture priorities seem pretty arbitrary, so I'd also like to add some documentation around why they were chosen.
Issue number: resolves #21769 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Toast does not support swipe gestures to dismiss. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Added a `swipeGesture` property that allows users to swipe toasts closed. Note: This is a combination of previous PRs #28380 and #28402⚠️ There is a visual glitch on iOS where dragging and having the toast animate back to its opened position causes a flicker. This is an iOS 17 regression and is being tracked in #28467. This bug has been reported to and confirmed by Apple. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->⚠️ Give co-author credit to author in #23124 --------- Co-authored-by: evgeniy-skakun <evgeniy-skakun@users.noreply.github.com>
Issue number: N/A
What is the current behavior?
Toast cannot be swiped to dismiss.
What is the new behavior?
positionAnchor
.getOffsetForMiddlePosition
util since we are doing this calculation in 3 different places.OVERLAY_GESTURE_PRIORITY
so we can begin to get better consistency with our gesture priorities.Note: There is a bug on iOS where swiping the toast and letting it snap back may cause a flicker. This is an underlying architecture bug that I plan to address in a separate PR. (I wasn't able to implement a fix today, but I felt it was important to get the other part of this implementation reviewed in the meantime)
Does this introduce a breaking change?
Other information