AngularJS animation card flip

后端 未结 2 801
清酒与你
清酒与你 2021-02-07 14:33

I am trying to use the new AngularJS way of doing animations between page transitions and would like to incorporate a card flip (like http://jsfiddle.net/nicooprat/GDdtS/)

相关标签:
2条回答
  • 2021-02-07 14:53

    I realize this was a long time ago, but I was just doing this, and it took zero javascript. The key is ng-class. Here is a JSFIDDLE.

    The key is this line

    <div class="card" ng-class="{'flipped':isFlipped}" ng-click="isFlipped=!isFlipped"> 
    

    It will assign the class 'flipped' to the card when $scope.isFlipped is true. Here is a little NFL flash cards game I put together for fun. Check out the source code (which isn't super pretty), it should be helpful if you are doing something like this.

    NFL Flash Cards

    0 讨论(0)
  • 2021-02-07 15:09

    Here is an alternate solution where it's more clear from the html what's happening. Specifically, the flip mechanism is in angularjs rather than buried in css magic. Perhaps easier to follow for anyone who's not a css expert:

    <div class="card" ng-click="isFlipped=!isFlipped">
        <div class="face front" ng-class="{'flipped':isFlipped}">
            Front
        </div> 
        <div class="face back" ng-class="{'flipped':!isFlipped}">
            Back
        </div> 
    </div>
    
    0 讨论(0)
提交回复
热议问题