SwiftUIModal icon indicating copy to clipboard operation
SwiftUIModal copied to clipboard

Background's transformation effects glitchy when drag gesture is interrupted

Open rrroyal opened this issue 6 years ago • 3 comments

When you're expanding modal view from .partiallyRevealed to .open, and the gesture is interrupted (i.e. Control Center is opened) background .scaleEffect, .mask and fading Rectangle() .opacity is stuck at the value when drag was interrupted.

Ways to replicate

  • Quickly open Control Center
  • Start opening modal and press Home button (minimize app)

rrroyal avatar Aug 03 '19 13:08 rrroyal

Oh, this is the same problem I was having in #1. Same thing happens when you trigger the animation without dragging, it just acts weird and the values don't update.

I was trying to force it to update by storing the scale/offset/opacity values in @State variables and changing the values when the ModalPosition changed, but didn't have a lot of luck with that.

I don't have much idea of what I'm doing when coding SwiftUI stuff so there might be some other ways of achieving this ¯_(ツ)_/¯

kevinrpb avatar Aug 05 '19 05:08 kevinrpb

I’ll take a look as soon as I commit the newest update to SwiftUIModal which adds a lot of flexibility and the ability to add as many modals as you want effortlessly. If I understood your issue correctly, it seems like it could be rectified with an ‘.onInterrupted’ on the DragGesture which doesn’t currently exist in SwiftUI. I’m pretty sure I have a workaround in mind. Does the modal still slide up, but other animations get interrupted?

cyrilzakka avatar Aug 05 '19 06:08 cyrilzakka

Yeah, the modal works great. It's the other values that don't get "caught" correctly.

A new version sounds great then, looking forward =D

kevinrpb avatar Aug 05 '19 06:08 kevinrpb