Animating the hand with transitions

During a game, the hand will be hidden when any overlay is shown. To make the app prettier, we will animate the hand when it is added or removed from the DOM. To do that, we will use CSS transitions together with a powerful Vue tool--the special <transition> component. It will help us work with CSS transitions when adding or removing elements with the v-if or v-show directives.

  1. First, add a new activeOverlay data property to the app state in the state.js file:
      // The consolidated state of our app      var state = {        // UI        activeOverlay: null,        // ...      }
  1. In the main template, we will show the hand component only if activeOverlay is not defined, thanks to the v-if directive:
      <hand :cards="testHand" v-if="!activeOverlay" ...

Get Vue.js 2 Web Development Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.