Skip to content

Need Swipe animation on button click #51

Open

Description

@Anujmoglix

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 ?

Activity

  1. AaronLavers commented on Jun 21, 2019

    @AaronLavers

    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.

  2. varnguyen commented on Jul 29, 2019

    @varnguyen

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

  3. jayseb11 commented on Apr 28, 2020

    @jayseb11

    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;
    }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions