angular2-swing icon indicating copy to clipboard operation
angular2-swing copied to clipboard

Need Swipe animation on button click

Open Anujmoglix opened this issue 5 years ago • 3 comments

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 ?

Anujmoglix avatar Mar 20 '19 06:03 Anujmoglix

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.

AaronLavers avatar Jun 21 '19 08:06 AaronLavers

@ 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);

varnguyen avatar Jul 29 '19 03:07 varnguyen

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;
}
}

jayseb11 avatar Apr 28 '20 15:04 jayseb11