Shuffle icon indicating copy to clipboard operation
Shuffle copied to clipboard

Swipe Card Temporarily Pauses After releasing Drag Gesture

Open Adamf155 opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Yes, currently when you swipe the card (left or right), a slight pause occurs after releasing the drag gesture. After releasing the drag gesture, the card stops abruptly then continues going in the direction the user swiped. This leads to a poorer user experience because it disobeys physics and the expected card movement the user is predicting.

Describe the solution you'd like

Make it so by default, after the user has crossed a certain location on the X axis (Positive and Negative) the card will automatically continue moving with its current speed/momentum even when the user releases the Drag Gesture.

Adamf155 avatar Jun 09 '20 21:06 Adamf155

Hi @Adamf155, thanks for reporting this issue. I am aware of this and it is something I have tried to address in the past.

To debug this, I would start by "building up" your cards again: do you see the issue with a blank card? A card with just your content and no overlays? Just overlays? This would help pin down what part of the card might be causing this issue during the animation. My current theory is that this happens when there is simply too much content to animate on the card.

I have a couple of additional suggestions that may help:

  • As we discussed, any background processing from the swipe should be kept off the main thread. When the swipe is registered, the library will calculate the final card position and animation time based on the pan gesture velocity. If I recall correctly, this calculation is done on the main thread.
  • Use lower quality images on your card. From informal experiments, I have noticed an improvement in performance (I also assume this is one of the reasons why swiping apps use lower resolution images)
  • If the content on your card is completely static (i.e. it will be rendered once and it is not a video or GIF), try enabling layer rasterization by writing the following:
    card.layer.shouldRasterize = true
    card.layer.rasterizationScale = UIScreen.main.scale
    
    This will render all layers of your card as a bitmap image and will improve performance. Some goods resources on this technique here and here.

By the way, are you seeing this issue only on the simulator? I have seen this issue on a device as well, but the simulator is an unreliable place to test GPU-intensive processes.

Let me know if any of the above works for you! If not, I will prioritize this issue and we can try to come up with a solution.

Mac

mac-gallagher avatar Jun 10 '20 09:06 mac-gallagher

Hi @mac-gallagher, I have this issue too; I don't know if it helps, but I have this issue only when swiping the card on the screen with fingers, with the simulator or a real device. If I swipe the card programmatically by calling .swipe(:animated), the animation is perfectly smooth. Thanks for your help!

benjamincombes avatar Oct 04 '21 14:10 benjamincombes