@@ -4,12 +4,13 @@ var t = `
44 <div :class="isActive(tab.id) ? 'text-gray-50' : 'text-transparent'" class="relative h-full">
55 <svg class="absolute right-0 bottom-0" fill="currentColor" width="7" height="7"><path d="M 0 7 A 7 7 0 0 0 7 0 L 7 7 Z"></path></svg>
66 </div>
7- <div @click="$emit('tab-activate', tab.id)"
7+ <div
8+ @click="$emit('tab-activate', tab.id)"
89 draggable="true"
9- @dragstart="dragStart (index, $event )"
10- @dragend="dragTab = dragOver = null "
11- @dragover.prevent
12- @dragfinish.prevent
10+ @dragstart="onDragStart (index)"
11+ @dragover.prevent="onDragOver(index) "
12+ @drop="onDrop"
13+ @dragend="onDragEnd"
1314 :title="tab.titleHover"
1415 :class="isActive(tab.id) ? 'bg-gray-50 text-gray-800' : 'hover:bg-gray-100/75 hover:text-gray-700 text-gray-500'"
1516 class="flex rounded-t-lg justify-between basis-52 truncate text-xs h-full items-center pl-3 pr-2 cursor-pointer">
@@ -24,17 +25,7 @@ var t = `
2425 <div :class="isActive(tab.id) ? 'text-gray-50' : 'text-transparent'" class="relative h-full">
2526 <svg class="absolute bottom-0" fill="currentColor" width="7" height="7"><path d="M 0 0 A 7 7 0 0 0 7 7 L 0 7 Z"></path></svg>
2627 </div>
27- <span
28- v-if="(dragTab != null && dragTab != index && index != dragTab - 1)"
29- v-text="dragOver === index ? getTabs[dragTab].title : '|'"
30- @dragenter="dragOver = index"
31- @dragleave="dragOver = null"
32- @drop.prevent="dragDrop(index)"
33- @dragover.prevent
34- :class="{'basis-52 truncate bg-gray-400 text-white text-xs pl-3 pr-2': (dragOver === index)}"
35- class="flex z-50 h-full justify-between items-center text-gray-500">
36- </span>
37- <span v-else :class="!isActive(tab.id) ? 'text-gray-300' : 'text-transparent'" class="z-1 -mr-1">|</span>
28+ <span :class="!isActive(tab.id) ? 'text-gray-300' : 'text-transparent'" class="z-1 -mr-1">|</span>
3829 </template>
3930</div>
4031`
@@ -46,19 +37,25 @@ export default {
4637 emits : [ 'tab-activate' , 'tab-move' , 'tab-close' , 'note-close' ] ,
4738 data ( ) {
4839 return {
49- dragTab : null ,
50- dragOver : null ,
40+ dragIndex : null ,
5141 }
5242 } ,
5343 methods : {
54- dragStart ( index , event ) {
44+ onDragStart ( index ) {
5545 this . $emit ( 'tab-activate' , this . tabs [ index ] . id )
56- this . dragTab = index ;
57- event . dataTransfer . dropEffect = 'move' ;
46+ this . dragIndex = index ;
5847 } ,
59- dragDrop ( index ) {
60- index = ( index > this . dragTab ) ? index : index + 1 ;
61- this . $emit ( 'tab-move' , this . tabs [ this . dragTab ] . id , index ) ;
48+ onDragOver ( overIndex ) {
49+ if ( this . dragIndex === null || this . dragIndex === overIndex ) return ;
50+
51+ this . $emit ( 'tab-move' , this . tabs [ this . dragIndex ] . id , overIndex ) ;
52+ this . dragIndex = overIndex ;
53+ } ,
54+ onDrop ( ) {
55+ this . dragIndex = null ;
56+ } ,
57+ onDragEnd ( ) {
58+ this . dragIndex = null ;
6259 } ,
6360 isActive ( tabId ) {
6461 return this . activeTabId == tabId ;
0 commit comments