Skip to content

support for <transition-group> (possibly through the React package: npmjs.com/package/transition-group) #3

Open
@faceyspacey

Description

@faceyspacey

They aren't working for me.

Here's an example I copied from the Vue docs:

<template>
  <div class='container'>
    <button v-on:click='add'>Add</button>
    <button v-on:click='remove'>Remove</button>

    <transition-group name='list' tag='p'>
      <span v-for='item in items' v-bind:key='item' class='list-item'>
        {{ item }}
      </span>
    </transition-group>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        items: [1,2,3,4,5,6,7,8,9],
        nextNum: 10
      }
    },
    methods: {
      randomIndex: function () {
        return Math.floor(Math.random() * this.items.length)
      },
      add: function () {
        this.items.splice(this.randomIndex(), 0, this.nextNum++)
      },
      remove: function () {
        this.items.splice(this.randomIndex(), 1)
      },
    }
  }
</script>
<style lang='stylus'>
.container
  background rgb(255, 190, 0)
  position absolute
  top 0px
  left 0px 
  width 100vw
  height 100vh
  display flex
  align-items center
  justify-content center
  & span
    color rgba(255,255,255, .5)
    font-size 32px

.list-item
  display inline-block
  margin-right 10px

.list-enter-active, .list-leave-active
  transition all 1s

.list-enter, .list-leave-to
  opacity 0
  transform translateY(30px)
</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions