ionic-team/ionic-ion-tinder-cards

Swipe events not always triggered (with possible fix)

ComedyTomedy opened this issue · 4 comments

If you pause before releasing a card near the edge, the card will swipe out, but won't run your onSwipeLeft() or onSwipeRight() function.

You can verify this by watching the console on any demo page.

(I previously thought I'd fixed it, but I was wrong. Problem seems to be that transitionOut() fires if the card's dropped beyond the threshold, but the onSwipe events don't.)

Changing the if at line 148 to fire events works, but fires the event twice on a fluid swipe (once on a drag-pause-drop). If it's possible to create custom events, e.g. onTdLeft and onTdRight, I presume that would solve it.

  if(this.x > 0) {
      targetX = (this.parentWidth / 2) + (this.width);
      this.onSwipeRight();
  } else {
      targetX = - (this.parentWidth + this.width);
      this.onSwipeLeft();
  }

You might try onTransitionLeft and onTransitionRight to see if that gives you the behavior you are wanting.

Solved! It does, thank you.

I suggest the demo html be updated to use on-transition-left/right, I can't imagine anybody would want to register swipes-but-not-drags, especially since it all looks the same to the end-user.

Thanks again :)

I will gladly approve a PR if you are willing to make that change. You might consider changing the code in the readme.md while you are at it.