|
25 | 25 | v-for="item in filteredCmdList" |
26 | 26 | :key="item.id" |
27 | 27 | class="flex-col items-center justify-between px-4 py-2 not-first:mt-2 hover:bg-bg-elevated select-none cursor-pointer rounded-md transition" |
28 | | - :class="{ 'bg-bg-subtle': item.id === selected }" |
| 28 | + :class="{ |
| 29 | + 'bg-bg-subtle': item.id === selected, |
| 30 | + 'trigger-anim': item.id === triggeringId, |
| 31 | + }" |
29 | 32 | @click="triggerCommand(item.id)" |
30 | 33 | > |
31 | 34 | <div class="text-fg">{{ item.name }}</div> |
@@ -68,6 +71,7 @@ const cmdList = [ |
68 | 71 | const selected = ref(cmdList[0]?.id || '') |
69 | 72 | const inputVal = ref('') |
70 | 73 | const show = ref(false) |
| 74 | +const triggeringId = ref('') |
71 | 75 | const inputRef = useTemplateRef('inputRef') |
72 | 76 |
|
73 | 77 | const { focused: inputFocused } = useFocus(inputRef) |
@@ -122,7 +126,11 @@ function toggle() { |
122 | 126 | function triggerCommand(id: string) { |
123 | 127 | const selectedItem = filteredCmdList.value.find(item => item.id === id) |
124 | 128 | selectedItem?.handler?.() |
125 | | - close() |
| 129 | + triggeringId.value = id |
| 130 | + setTimeout(() => { |
| 131 | + triggeringId.value = '' |
| 132 | + close() |
| 133 | + }, 100) |
126 | 134 | } |
127 | 135 |
|
128 | 136 | const handleKeydown = useThrottleFn((e: KeyboardEvent) => { |
@@ -169,4 +177,25 @@ defineExpose({ |
169 | 177 | opacity: 0; |
170 | 178 | transform: translateY(-10px); |
171 | 179 | } |
| 180 | +
|
| 181 | +@keyframes trigger-pulse { |
| 182 | + 0% { |
| 183 | + transform: scale(1); |
| 184 | + background-color: var(--bg-subtle); |
| 185 | + } |
| 186 | +
|
| 187 | + 50% { |
| 188 | + transform: scale(0.96); |
| 189 | + background-color: var(--bg-elevated); |
| 190 | + } |
| 191 | +
|
| 192 | + 100% { |
| 193 | + transform: scale(1); |
| 194 | + background-color: var(--bg-subtle); |
| 195 | + } |
| 196 | +} |
| 197 | +
|
| 198 | +.trigger-anim { |
| 199 | + animation: trigger-pulse 0.1s ease-in-out; |
| 200 | +} |
172 | 201 | </style> |
0 commit comments