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

Swipe Card Temporarily Pauses After releasing Drag Gesture #78

Open
Adamf155 opened this issue Jun 9, 2020 · 2 comments
Open

Swipe Card Temporarily Pauses After releasing Drag Gesture #78

Adamf155 opened this issue Jun 9, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@Adamf155
Copy link

Adamf155 commented Jun 9, 2020

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 Adamf155 added the enhancement New feature or request label Jun 9, 2020
@mac-gallagher mac-gallagher added bug Something isn't working and removed enhancement New feature or request labels Jun 10, 2020
@mac-gallagher
Copy link
Owner

mac-gallagher commented Jun 10, 2020

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 mac-gallagher pinned this issue Jul 4, 2020
@benjamincombes
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants