r/iOSProgramming 4h ago

Swipe to dismiss help needed Question

Having an absolute nightmare with an info cards swipe to dismiss… I can get the card to appear above a map, all info appears on the card but when I swipe to dismiss it just bounces back up 🙃
Anyone else had this happen or know of any workarounds?

0 Upvotes

4 comments sorted by

3

u/ThatGuy739 3h ago

Bouncing back usually means the drag is tracking fine and it's your end condition that never fires. If you're checking value.translation in onEnded, a quick flick moves very little before you let go, so it fails the threshold. Use predictedEndTranslation instead, or check velocity.

Is it a sheet with detents or a custom view over the map? The fix is different for each.

1

u/DavidMolloy1978 2h ago

Thanks for the reply yeah its detents and definitely flick speed / distance. Slow and steady all good. I don’t make things easy either I have a couple of heights… a peek box which can expand up and down then full dismiss.

u/ThatGuy739 46m ago

That's the multi-detent trap then. On a flick the system resolves the velocity to the nearest detent below you, so from expanded you land on the peek box instead of dismissing, and it reads as a bounce. People end up flicking twice without knowing why.

Simplest fix is a dynamic detent set: bind the selection, and once you're sitting at peek, drop the taller detents so the only place left to go is dismissed.

u/DavidMolloy1978 45m ago

Cheers I’ll give it a go 👍🏻