Skip to content

Commit d67a892

Browse files
committed
feat: add some cool animataions :P
1 parent 36aeb30 commit d67a892

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

app/components/Scan.vue

+34-9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ const length = computed(() => chunks.find(i => i?.[1])?.[1] || 0)
130130
const id = computed(() => chunks.find(i => i?.[0])?.[0] || 0)
131131
const picked = computed(() => Array.from({ length: length.value }, (_, idx) => chunks[idx]))
132132
const dataUrl = ref<string>()
133+
const dots = useTemplateRef<HTMLDivElement[]>('dots')
134+
135+
function pluse(index: number) {
136+
const el = dots.value?.[index]
137+
if (!el)
138+
return
139+
el.style.transition = 'none'
140+
el.style.transform = 'scale(1.3)'
141+
el.style.filter = 'hue-rotate(90deg)'
142+
// // force reflow
143+
void el.offsetWidth
144+
el.style.transition = 'transform 0.3s, filter 0.3s'
145+
el.style.transform = 'none'
146+
el.style.filter = 'none'
147+
}
133148
134149
async function scanFrame() {
135150
shutterCount.value += 1
@@ -146,6 +161,7 @@ async function scanFrame() {
146161
const data = JSON.parse(result.text) as SliceData
147162
if (Array.isArray(data)) {
148163
chunks[data[2]] = data
164+
pluse(data[2])
149165
150166
// Bandwidth calculation
151167
{
@@ -188,19 +204,28 @@ watch(() => results.value.size, (size) => {
188204
<a v-if="dataUrl" :href="dataUrl" download="foo.png">Download</a>
189205
<pre v-if="error" text-red v-text="error" />
190206
<div relative h-full max-h-150 max-w-150 w-full>
191-
<video ref="video" autoplay muted playsinline aspect-ratio-1 h-full w-full controls="false" />
207+
<video ref="video" autoplay muted playsinline aspect-ratio-1 h-full w-full rounded-lg controls="false" />
192208
<p absolute bottom-1 right-1 border rounded-md bg-black px2 py1 text-white font-mono shadow>
193209
{{ fps.toFixed(0) }}hz | {{ shutterCount }} | {{ currentBandwidthFormatted }}
194210
</p>
211+
<div absolute left-1 right-1 top-1>
212+
<div flex="~ gap-0.4 wrap">
213+
<div
214+
v-for="x, idx in picked"
215+
:key="idx"
216+
ref="dots"
217+
h-4
218+
w-4
219+
border="~ gray rounded"
220+
:class="x ? 'bg-green border-green4' : 'bg-gray:50'"
221+
/>
222+
</div>
223+
<div mt-1 w-max rounded bg-black:40 px1 text-sm>
224+
{{ picked.filter(p => !!p).length }} / {{ length }}
225+
</div>
226+
</div>
195227
</div>
196-
<div flex="~ gap-1 wrap" max-w-150 w-full>
197-
<div
198-
v-for="x, idx in picked" :key="idx"
199-
h-5 w-5
200-
border="~ gray:10 rounded"
201-
:class="x ? 'bg-green' : '' "
202-
/>
203-
</div>
228+
204229
<div>{{ { length, id } }}</div>
205230
<!-- <div>{{ chunks }}</div> -->
206231
</div>

0 commit comments

Comments
 (0)