CardStackView
CardStackView copied to clipboard
How to set swipe Direction only one side
This could use some documentation expansion if you'd like to submit a PR to update it.
You can setup the swipeable directions on the CardStackLayoutManager
:
cardStackView.layoutManager = CardStackLayoutManager(requireContext(), this).apply {
setDirections(listOf(Direction.Right))
}
this doesn't seem to work. I tried setting Direction.Left but it allows swipe in all directions akin to Direction.FREEDOM.
Hmm this is working for me. It doesn't limit all motion in the other directions, but will limit which directions result in the card actually swiping away.
Are you looking for a way to prevent any motion at all except for a single direction?
@Barryrowe yes, just the way setting setCanScrollHorizontal = true works, just that now I want cards to swipe only in one direction (i.e. Left) while the other direction swipe is blocked.
Any suggestions how this can be achieved?
I'm not sure with the current API. I think the library would have to be extended to include finer grained options like:
canScrollHorizontalLeft canScrollHorizontalRight canScrollVerticalTop canScrollVerticalBottom
actually, I am using CardStack in a Fragment inside of a ViewPager. It is conflicting with swipe right gesture of ViewPager which should open another page.
That's a much bigger undertaking, and will likely require overriding onInterceptTouchEvent
at some point in your view heirarchy. I don't think there's anything on the CardStackView that is intended to support that scenario out of the box.