JSFiddle - React, Tailwind, and code Playground

by Jonathan Heron

HTML

<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/sortable/1.4.2/Sortable.min.js"></script>
<script src="https://cdn.rawgit.com/David-Desmaisons/Vue.Draggable/master/dist/vuedraggable.min.js"></script>

<div id="app">
  <div>
    <h1>
    List 1
    </h1>
    <draggable class="warp-div" v-model="myArray" :options="{group:'people'}">
      <div class="div" :style="'background-color:'+element.color" v-for="element in myArray">{{element.name}}</div>
    </draggable>
  </div>
  
  <div>
    <h1>
    List 2
    </h1>
    <p>
      Show fake, static list: {{hideListTwo}}
    </p>
    <!-- Real, draggable list -->
    <draggable class="warp-div" v-model="mySecondArray" :options="{group:'people'}" @remove="removed">
      <transition-group tag="div" mode="out-in" name="disabled" v-show="!hideListTwo">
        <div class="div" :style="'background-color:'+element.color" v-for="element in mySecondArray" :key="element.name">{{element.name}}</div>
      </transition-group>
    </draggable>
    
    <!-- Fake, non-draggable list, shown for a moment while transition-group blips -->
    <div v-show="hideListTwo">
      <div class="div" :style="'background-color:'+element.color" v-for="element in mySecondArray" :key="element.name">{{element.name}}</div>
    </div>
    
  </div>
  
  
    <div style="position:absolute; top: 250px;">
    <br><br><br>
    <h1>
    List 2 (data output, not editable)
    </h1>
      <transition-group tag="div" mode="out-in" name="disabled">
        <div class="divstatic" :style="'background-color:'+element.color" v-for="element in mySecondArray" :key="element.name">{{element.name}}</div>
        </transition-group>
  </div>
  
</div>

CSS

*, h1 {
  font-size: 15px;
  font-family: Arial;
}
.div {
  width: 90%;
  border: 1px solid gray;
  margin: 5px;
  padding: 3px;
}

.divstatic {
  width: 90%;
  border: 1px dotted gray;
  margin: 5px;
  padding: 3px;
}

.disabled-enter-active, .disabled-leave-active {
  transition: none !Important
}

JavaScript

// Vue version
new Vue({
  el: '#app',
  data: {
  	myArray: [
        {'name': 'A', order: 1},
        {'name': 'B', order: 2},
        {'name': 'C', order: 3}
      ],
  	mySecondArray: [
        {'name': '1', order: 1},
        {'name': '2', order: 2},
        {'name': '3', order: 3}
      ],
    hideListTwo: false
  },
  methods:{
    removed: function () {
    	this.hideListTwo = true
      var self = this
      Vue.nextTick(function () {
	      // show the real list again
        // waiting for nextTick isn't enough
	      setTimeout(function(){self.hideListTwo = false}, 100)
      })
    }
  }
})