Utilizing Facebook’s POP animation framework to simplify things, and offer an even more from the package animation that is dynamic we use a POPBasicAnimation into the card translating it is X and Y origin to a value from the display screen.

When this animation is complete I call my delegate function self.delegate?.didEndSwipe(onView: self) and depend on my delegate (which added this SwipeableView as being a subview) to get rid of this SwipeableView being a subview. This card happens to be totally taken out of the stack and its own work is completed.

In the event that dragPercentage just isn’t 60% or maybe more, or if perhaps the pan gesture’s state is terminated or failed, i have to back animate it to the stack. Typically this animation may be just a little rubber-band-like springy bounce animation that communicates that the swipe failed therefore the individual has ‘let go’ regarding the card, allowing it to fling back once again to its initial destination, just as you’ll expect within the real life physics space. (more…)