tangled
alpha
login
or
join now
pds.ls
/
pdsls
398
fork
atom
atmosphere explorer
pds.ls
tool
typescript
atproto
398
fork
atom
overview
issues
pulls
pipelines
image opening/closing animation
juli.ee
3 days ago
72347c54
048f8dfe
verified
This commit was signed with the committer's
known signature
.
juli.ee
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+18
-4
1 changed file
expand all
collapse all
unified
split
src
components
json.tsx
+18
-4
src/components/json.tsx
···
318
318
319
319
const MediaDisplay = () => {
320
320
const [expanded, setExpanded] = createSignal(false);
321
321
+
const [closing, setClosing] = createSignal(false);
322
322
+
323
323
+
const closeExpanded = () => {
324
324
+
setClosing(true);
325
325
+
setTimeout(() => {
326
326
+
setExpanded(false);
327
327
+
setClosing(false);
328
328
+
}, 200);
329
329
+
};
321
330
322
331
createEffect(() => {
323
332
if (!expanded()) return;
324
333
const handler = (e: KeyboardEvent) => {
325
325
-
if (e.key === "Escape") setExpanded(false);
334
334
+
if (e.key === "Escape") closeExpanded();
326
335
};
327
336
window.addEventListener("keydown", handler);
328
337
onCleanup(() => window.removeEventListener("keydown", handler));
···
364
373
<Show when={expanded()}>
365
374
<Portal>
366
375
<div
367
367
-
class="fixed inset-0 z-50 flex cursor-zoom-out items-center justify-center bg-black/80"
368
368
-
onclick={() => setExpanded(false)}
376
376
+
class="fixed inset-0 z-50 flex cursor-zoom-out items-center justify-center bg-black/80 transition-opacity duration-200 starting:opacity-0"
377
377
+
classList={{ "opacity-0": closing() }}
378
378
+
onclick={closeExpanded}
369
379
>
370
370
-
<img class="max-h-screen max-w-screen object-contain" src={imageUrl()} />
380
380
+
<img
381
381
+
class="max-h-screen max-w-screen object-contain transition-all duration-200 starting:scale-95 starting:opacity-0"
382
382
+
classList={{ "scale-95 opacity-0": closing() }}
383
383
+
src={imageUrl()}
384
384
+
/>
371
385
</div>
372
386
</Portal>
373
387
</Show>