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 'swipeGesture' property to dismiss toasts via swipe(… #23124

Closed
wants to merge 1 commit into from

Conversation

evgeniy-skakun
Copy link
Contributor

@evgeniy-skakun evgeniy-skakun commented Mar 31, 2021

…TakumaKira) - expanded

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

#21769

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot added the package: core @ionic/core package label Mar 31, 2021
@liamdebeasi
Copy link
Contributor

Thanks for the PR. What is the difference between this PR and the previous toast swipe gesture PR? (#22133).

@evgeniy-skakun
Copy link
Contributor Author

@liamdebeasi Please check the extended version of the PR [ @TakumaKira ] #22133

@evgeniy-skakun
Copy link
Contributor Author

@liamdebeasi Added "vertical" and "horizontal" swipe

@liamdebeasi
Copy link
Contributor

What is the difference between a horizontal swipe and a swipe from the left or right?

@evgeniy-skakun
Copy link
Contributor Author

@liamdebeasi You can swipe in both directions instead of just one.

@liamdebeasi
Copy link
Contributor

Do you have any use cases for this? I wonder if it makes sense to just have the options be 'horizontal' | 'vertical' and determine the direction based upon where the toast was presented from.

For example, if the toast was presented from the bottom and I had swipeGesture="vertical" set, I can't imagine there is a use case where I would want to swipe up to dismiss. I would expect that I would just swipe down to dismiss since it is closest to the bottom edge of the screen.

Similarly, is there any benefit to only letting someone swipe to the left to dismiss versus being able to swipe to the left or the right?

@evgeniy-skakun
Copy link
Contributor Author

vertical swipe will be useful if the toast is placed in the center of the screen.

horizontal swipe can be useful if the application is used by left-handers and right-handers.

@liamdebeasi In any case, if you do not see any use in them, then they can be removed.

@liamdebeasi
Copy link
Contributor

Thanks for the clarification, that makes sense. I think in that case we can infer the direction based upon the position prop value.

If position="bottom" then swiping down would dismiss the toast.
If position="top" then swiping up would dismiss the toast.
If position="middle then swiping up or down would dismiss the toast.

Do you have any examples of the horizontal swipe in existing applications? I like the vertical swipe, but my concern with the horizontal swipe is that it is does not seem to exist in the Material Design spec.

@evgeniy-skakun
Copy link
Contributor Author

20210331_195252.mp4

Samsung allows you to swipe in both directions

@liamdebeasi
Copy link
Contributor

Those looks like Android-specific notification center components, not a toast/snackbar. Do you have any examples of this horizontal gesture with a toast/snackbar?

For example, the Snackbar Flutter demo on https://material.io/components/snackbars only lets you do a vertical swipe.

@evgeniy-skakun
Copy link
Contributor Author

@liamdebeasi I don't have an example app.

I can remove the horizontal swipe if you think it doesn't make sense.

@liamdebeasi
Copy link
Contributor

No problem, was just curious you knew of an example. I do see the benefit of this feature, so I think this is something we should add.

This is a new API, so it would need to go into a minor release. We are focusing on patch releases and the new major version of Ionic Framework at the moment, but I can add this to our project board and we will do a full review as we get closer to planning a new minor release.

}

private clamp = (val: number) => {
if (val > 1) {

Choose a reason for hiding this comment

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

Can this be simplified?

return val > 1 ? 1 : Math.max(0, val);

@reslear
Copy link

reslear commented Sep 13, 2021

any news?

@katche70
Copy link

Hi Ionic Team,
It would be great if this feature comes in the official Ionic release

@thekhegay
Copy link

Any updates?

@bstrasburg
Copy link

Any updates ????

@philmmoore
Copy link

I'd find this useful in my apps too :)

@EinfachHans
Copy link
Contributor

EinfachHans commented Jul 6, 2022

can't wait to se this in the framework

@katche70
Copy link

katche70 commented Dec 7, 2022

Hey whats going on here with this open PR ? Nobody form ionic Team here to add this in official ionic release. Would by nice to have this feature, because it would be feel more native for ios user. Push Messages from ios simply can swipe up

@liamdebeasi
Copy link
Contributor

Hi everyone,

The team met a few weeks ago to discuss this PR, and we are interested in adding this feature. The next step is for the team to do a feature design document. This is where we determine the scope, requirements, and architecture of the feature to help ship a reliable API. Once that has been approved, someone from the team will review the PR and help make any changes necessary to get this PR ready to merge.

Our primary focus right now is getting Ionic 7.0 into beta, which is why you have not seen much movement on this PR over the past few weeks. While I do not have a timeline for when this will merge, we recognize that this is an important feature for Ionic developers. Let me know if there are any questions. Thanks!

@benmarsh
Copy link

benmarsh commented Dec 9, 2022

This is great news - thanks for the update @liamdebeasi :)

@rsammelson
Copy link

Is there any update on this being completed? Would a new PR with conflicts resolved be useful to that process?

@sarevok89
Copy link

Is there any update on this? The PR has been opened more than 2 years above 😞

@danieljancar
Copy link

Any updates on the feature, since Ionic 7 is out?

@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>
@liamdebeasi
Copy link
Contributor

Hey there! Thanks for contributing this PR, and apologies for the delay in replying here. This feature was added to Ionic in #28442. The work you did here helped us build out the final implementation, so we've given you co-author credit in the commit that was merged.

This feature will be available in an upcoming minor release of Ionic. I am going to close this, and thanks again for contributing to Ionic!

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