Skip to content

Commit f61b431

Browse files
committed
web/app: tabs - animate tab reordering for visual clarity
1 parent 03610fd commit f61b431

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

web/app/nav-tabs.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
var t = `
2-
<div class="flex flex-nowrap max-w-full w-full h-9 overflow-x-hidden items-center content-center px-2 mr-6">
3-
<template v-for="tab, index in getTabs" :key="tab.id">
2+
<TransitionGroup name="nav-tabs" tag="div"
3+
leave-active-class="transition-none"
4+
enter-active-class="transition-transform duration-200 ease-in-out"
5+
move-class="transition-transform duration-250 ease-in-out"
6+
class="flex flex-nowrap max-w-full w-full h-9 overflow-x-hidden items-center px-2 mr-6">
7+
<div v-for="(tab, index) in getTabs" :key="tab.id" class="flex items-center h-full flex-1 min-w-0 max-w-[13rem]">
48
<div :class="isActive(tab.id) ? 'text-gray-50' : 'text-transparent'" class="relative h-full">
59
<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>
610
</div>
@@ -13,21 +17,21 @@ var t = `
1317
@dragend="onDragEnd"
1418
:title="tab.titleHover"
1519
:class="isActive(tab.id) ? 'bg-gray-50 text-gray-800' : 'hover:bg-gray-100/75 hover:text-gray-700 text-gray-500'"
16-
class="flex rounded-t-lg justify-between basis-52 truncate text-xs h-full items-center pl-3 pr-2 cursor-pointer">
17-
<span class="truncate pt-px">
18-
<span v-show="tab.isModified" class="inline-block h-2 w-2 rounded-full bg-yellow-400 mr-2"></span>
19-
<span v-text="tab.title"></span>
20-
</span>
20+
class="flex items-center justify-between rounded-t-lg text-xs h-full pl-3 pr-2 cursor-pointer w-full truncate">
21+
<div class="flex items-center gap-2 truncate min-w-0">
22+
<span v-show="tab.isModified" class="inline-block h-2 w-2 rounded-full bg-yellow-400"></span>
23+
<span class="truncate" v-text="tab.title"></span>
24+
</div>
2125
<span @click.stop="handleClose(tab.id, tab.type)" class="hover:bg-gray-300 hover:rounded-full">
2226
<Icon name="mini-x-mark" size="h-4 w-4" />
2327
</span>
2428
</div>
2529
<div :class="isActive(tab.id) ? 'text-gray-50' : 'text-transparent'" class="relative h-full">
2630
<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>
2731
</div>
28-
<span :class="!isActive(tab.id) ? 'text-gray-300' : 'text-transparent'" class="z-1 -mr-1">|</span>
29-
</template>
30-
</div>
32+
<span :class="!isActive(tab.id) ? 'text-gray-300' : 'text-transparent'" class="z-1 -mr-1 -mt-[3px]">|</span>
33+
</div>
34+
</TransitionGroup>
3135
`
3236

3337
import Icon from './icon.js'
@@ -38,6 +42,7 @@ export default {
3842
data() {
3943
return {
4044
dragIndex: null,
45+
dragOverEnabled: true,
4146
}
4247
},
4348
methods: {
@@ -46,10 +51,14 @@ export default {
4651
this.dragIndex = index;
4752
},
4853
onDragOver(overIndex) {
54+
if (!this.dragOverEnabled) return;
4955
if (this.dragIndex === null || this.dragIndex === overIndex) return;
5056

5157
this.$emit('tab-move', this.tabs[this.dragIndex].id, overIndex);
5258
this.dragIndex = overIndex;
59+
60+
this.dragOverEnabled = false;
61+
setTimeout(() => { this.dragOverEnabled = true; }, 300);
5362
},
5463
onDrop() {
5564
this.dragIndex = null;

0 commit comments

Comments
 (0)