ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.09k stars 13.51k forks source link

feat: sheet/card modal emit drag #23955

Open EinfachHans opened 3 years ago

EinfachHans commented 3 years ago

Prequisites

Describe the Feature Request

If a FR like this already exist, please close, but i didn't found one.

It would be great to be able to "dig" into Animations and Gestures that are used in the Ionic Framework.

Describe the Use Case

It would allow us to show, hide or transform & animate stuff in the app while the user performs something. For example with the new sheet style modal we could fade content in or out if the modal is dragged up or dragged down.

Also this can be used for navigation animations.

Describe Preferred Solution

I guess this is kinda tricky, as this can be either defined globally or per component.

For example if i want to implement this for a Modal it must be possible for me to add this in the Component that the Modal uses like

this.modal.animation.subscribe()

Describe Alternatives

Currently i think something like this is possible if we copy/paste all the animations/gestures from ionic into our app and modify to call a handler, but this is not very good, as it doesn't update the animations if you update it internally 🤔

Related Code

No response

Additional Information

No response

liamdebeasi commented 3 years ago

Can you please clarify what it means to "dig into an animation" in Ionic? It sounds like you are looking to get drag events emitted from the modal with the sheet gesture?

EinfachHans commented 3 years ago

Yes exactly. But not only the Drag Gesture and not only the Sheet Modal. If for example (when possible in the future) the sheet modal is changed via a function it should also executy my listener to perform my animations.

Or if we talk about Page Transistions this should work on the first navigate, as well on the navigate back or swipe to go back.

liamdebeasi commented 3 years ago

Some of these animations/transitions are not meant to be extended/customized, so I would prefer not to add this feature to every animation unless we have use cases for each one.

The sheet modal use case makes sense (we have also had people ask about this internally), so I think we can add that one.

EinfachHans commented 3 years ago

Yeah maybe every animation was too much 😃 But i wouldn't limit this on sheet modals, we could start with modals in generall?

liamdebeasi commented 3 years ago

How would regular modals benefit from the drag event?

EinfachHans commented 3 years ago

I think of the Card style modal which is also swipable, so here it wouldn't be showing or hiding more or less content, it would be more having the posibility to do cool animations when draging the modal away

liamdebeasi commented 3 years ago

Thanks -- makes sense to have this work for card modal too.

JulesLagadic commented 2 years ago

Hello, Any news about this issue? Would be amazing to get a way to subscribe to the drag event... Any workaround possible?

sean-perkins commented 2 years ago

Added additional thoughts here: https://github.com/ionic-team/ionic-framework/issues/25127#issuecomment-1104375899

Summary: We should add a dragEvents property to ion-modal, to allow developers to subscribe to the drag events for both card and sheet modals. Sheet modals should likely include information related to the breakpoint as well.

sean-perkins commented 2 years ago

Found an example of where this feature could be leveraged in Instagram's app:

https://user-images.githubusercontent.com/13732623/173140650-5acfce46-72c9-4743-b1a9-059fd4a27193.mp4

They center the active location in the middle of the content behind the sheet modal, when the sheet modal begins to drag.

JulienLecoq commented 1 year ago

I also needs that to be able to hide dynamically some content when a modal is dragged 👍🏻

sean-perkins commented 1 year ago

Airbnb has UI that would require this feature, where the tab bar is moved off screen as the sheet modal is dragged.

https://github.com/ionic-team/ionic-framework/assets/13732623/9dd29c11-36a5-4381-904c-eec283ab606c

greg-md commented 1 year ago

In 2 years it was not implemented yet. :(

aeharding commented 12 months ago

Another use case: I would like to have a dragStart and dragEnd events on card modal to open and close the keyboard.

Sovai commented 10 months ago

2024 still waiting for dragStart/dragEnd events