Skip to content
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

Merged
merged 34 commits into from
Nov 6, 2023
Merged

feat(toast): add swipe gesture implementation #28402

merged 34 commits into from
Nov 6, 2023

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Oct 24, 2023

Issue number: N/A


What is the current behavior?

Toast cannot be swiped to dismiss.

What is the new behavior?

  • Implements a swipe gesture that allows the toast to be dismissed. This includes support for positionAnchor.
  • Added a getOffsetForMiddlePosition util since we are doing this calculation in 3 different places.
  • Added 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)

⚠️ This PR focuses on the base functionality of the swipe gesture. This means things like the animation duration, the easing curve, the rubber band effect when dragging the wrong way are not part of this PR. I will address these separately. I wanted to allow reviewers to focus on the functionality before we start to tweak the parameters of this animation.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot added the package: core @ionic/core package label Oct 24, 2023
@liamdebeasi liamdebeasi changed the title 2004 swipe feat(toast): add swipe gesture implementation Oct 24, 2023
@liamdebeasi liamdebeasi marked this pull request as ready for review October 24, 2023 19:59
@liamdebeasi liamdebeasi requested review from a team and brandyscarney and removed request for a team October 24, 2023 19:59
Base automatically changed from 2004-prop to FW-2004 October 25, 2023 14:34
Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, works great!

@liamdebeasi liamdebeasi requested a review from a team November 2, 2023 20:23
@@ -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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@liamdebeasi liamdebeasi merged commit 5e4b58b into FW-2004 Nov 6, 2023
43 checks passed
@liamdebeasi liamdebeasi deleted the 2004-swipe branch November 6, 2023 22:49
@liamdebeasi liamdebeasi mentioned this pull request Nov 7, 2023
2 tasks
liamdebeasi added a commit that referenced this pull request Nov 13, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants