yuyakaido / CardStackView

📱Tinder like swipeable card view for Android
Apache License 2.0
2.37k stars 448 forks source link

Cancel automatic swipe #248

Open nivBlox opened 5 years ago

nivBlox commented 5 years ago

Hey, first of all i would like to say the you created awesome library!

I'm trying to show some kind of "tooltip" or similar to it. By make an auto swipe and in half way cancel it (some kind of example to the user how to swipe) but its not cancelled..

Is there any solution for that? and if not how can i cancel an automatic swipe?

Thank you for your help, Niv

yuyakaido commented 5 years ago

@nivBlox Thank you for your comment!

Currently, we have no way to cancel automatic swipe in half way. But we can implement similar behavior with automatic swipe and rewind.

  1. Automatic Swipe -> Top card is swiped
  2. Rewind -> Swiped card is rewound

And I think tooltip is a common usecase so I think of this feature in next major release.

nivBlox commented 5 years ago

@yuyakaido Hey, thats what i tried to do but its not working. as i said its not canceling the auto swipe.. view.cardStackView.swipe() view.cardStackView.rewind()

nivBlox commented 5 years ago

@yuyakaido the rewind doesn't work before the swipe is finishing... there is any work around for that?

eikkk commented 4 years ago

I was trying to rewind card from onCardSwiped method and it didn't work for me as well. When I postDelayed it for my animation duration time the rewind worked correctly.

so, for anybody who also faced this issue, you can use something like: new Handler(Looper.getMainLooper()).postDelayed(() -> cardStackViewPitches.rewind(), Duration.Normal.duration);

TonyLead commented 1 month ago

@eikkk hi, you saved my day

TonyLead commented 1 month ago

new Handler(Looper.getMainLooper()).postDelayed(() -> cardStackViewPitches.rewind(), Duration.Normal.duration);

the best solve