JoniVR / VerticalCardSwiper

A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] How to stop backwards scrolling?

Harryjeffs opened this issue · comments

commented

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

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!

commented

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.

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)

commented

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.

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 ;)