angular2-swing
angular2-swing copied to clipboard
Need Swipe animation on button click
Hi , I need left swipe animation on left button click and right swipe animation on right button click like tinder or any other app. Is it possible with this plugin ?
I've also been searching for a solution to this. I can see that there's a card.throwOut function in the Card.js module, however trying to target it from a button seems to be difficult. I see there is a closed issue from a couple of years ago where someone found the solution but didn't share it.
@ Anujmoglix I think this is what you need but for it to move smoothly like I don't know.
const firstNativeElement = this.swingCards.first.getNativeElement();
// Right click
this.swingStack.stack.getCard(firstNativeElement).throwOut(-1, 0);
// Left click
this.swingStack.stack.getCard(nativeElementFirst).throwOut(1, 0);
Found a solution that works reasonably well:
voteUp(like: boolean) {
if (this.cards.length > 0 && this.swingCards.last) {
const topNativeElement = this.swingCards.last.getNativeElement();
this.renderer.addClass(topNativeElement, "throw-card");
}
setTimeout(() => {
this.cards.pop();
}, 180);
}
.throw-card {
animation: linear;
animation-name: slideright;
animation-duration: 200ms;
animation-iteration-count: 1
}
@keyframes slideright {
0% {
left: 0;
}
100% {
left: 100vw;
}
}