JoniVR / VerticalCardSwiper

A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.
MIT License
1.4k stars 101 forks source link

[Question] How to stop backwards scrolling? #52

Closed Harryjeffs closed 5 years ago

Harryjeffs commented 5 years ago

New Issue Checklist

Question

Is there a method for only scrolling down rather than allowing scrolling both ways? Disabling the last card just swiped to be visible again? Cheers

JoniVR commented 5 years ago

Hi @Harryjeffs

I can't think of a way to do this with the current API, but keep in mind that this is entirely built with a UICollectionView, which in turn uses a UIScrollView internally, so you should be able to override the behaviour yourself.

The structure is: VerticalCardSwiper is a subclass of UIView, which embeds a UICollectionView subclass called VerticalCardSwiperView.

So while it's not technically supported, I think you should be able to achieve it by extending VerticalCardSwiperView yourself in some way, by overriding scrollView behaviour.

A PR for this is always welcome too, hope this helps!

Harryjeffs commented 5 years ago

I found the use of PanDirection which includes a down variable. I'll have a look and if I have any luck, make a PR.

JoniVR commented 5 years ago

I found the use of PanDirection which includes a down variable

I'm not sure if PanDirection will be what you need here. Sure, you could perhaps use it, but there are probably better solutions.

Any update on this? Did you find out how to do it? (just so I can close the issue if you found it already or try helping you out if not)

Harryjeffs commented 5 years ago

I eventually opted for finding the vertical scroll direction and disabling scrolling in that direction. I'll make a pull request once I can find the time to tidy it up. Cheers.

JoniVR commented 5 years ago

I'll make a pull request once I can find the time to tidy it up. Cheers.

You don't really have to tbh, it's good to know the solution in case anyone else want to achieve the same thing though, Glad you found it ;)