misc: tweak css animations (#583)

* impr: use css animations instead of svelte for comments

* impr: change post load animation
This commit is contained in:
Xylight authored and GitHub committed 2025-06-16 12:15:27 -07:00
1 parent 0de8758996
commit 42d755b46b
3 files changed
+38 -17

No files matched your search

@@ -10,9 +10,7 @@
import { errorMessage } from '$lib/lemmy/error' import { errorMessage } from '$lib/lemmy/error'
import { Button, Modal, toast } from 'mono-svelte' import { Button, Modal, toast } from 'mono-svelte'
import { Bookmark, Icon, Microphone, Pencil, Trash } from 'svelte-hero-icons' import { Bookmark, Icon, Microphone, Pencil, Trash } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import type { ClassValue } from 'svelte/elements' import type { ClassValue } from 'svelte/elements'
import { slide } from 'svelte/transition'
import ShieldIcon from '../moderation/ShieldIcon.svelte' import ShieldIcon from '../moderation/ShieldIcon.svelte'
import CommentForm from './CommentForm.svelte' import CommentForm from './CommentForm.svelte'
import type { CommentNodeI } from './comments.svelte' import type { CommentNodeI } from './comments.svelte'
@@ -74,6 +72,16 @@
editingLoad = false editingLoad = false
} }
$effect(() => {
if (!open) {
// const
}
})
setTimeout(() => {
open = true
}, 500)
</script> </script>
{#if editing || replying} {#if editing || replying}
@@ -202,11 +210,8 @@
</span> </span>
</button> </button>
{/if} {/if}
{#if open} <div class={['expand', open && 'open', contentClass]}>
<div <div id="comment-content">
class="relative {contentClass}"
transition:slide={{ duration: 400, easing: expoOut }}
>
<div <div
class="flex flex-col whitespace-pre-wrap class="flex flex-col whitespace-pre-wrap
max-w-full gap-1 mt-1 relative" max-w-full gap-1 mt-1 relative"
@@ -229,5 +234,22 @@
{@render children?.()} {@render children?.()}
</div> </div>
</div> </div>
{/if} </div>
</li> </li>
<style>
.expand {
display: grid;
grid-template-rows: 0fr;
overflow: hidden;
transition: grid-template-rows 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}
.expand.open {
grid-template-rows: 1fr;
}
.expand > * {
min-height: 0;
}
</style>
@@ -4,16 +4,14 @@
import { page } from '$app/state' import { page } from '$app/state'
import { t } from '$lib/i18n/translations' import { t } from '$lib/i18n/translations'
import { getClient } from '$lib/lemmy.svelte.js' import { getClient } from '$lib/lemmy.svelte.js'
import { errorMessage } from '$lib/lemmy/error'
import type { Post } from 'lemmy-js-client' import type { Post } from 'lemmy-js-client'
import { Button, toast } from 'mono-svelte' import { Button, toast } from 'mono-svelte'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { ArrowDownCircle, Icon } from 'svelte-hero-icons' import { ArrowDownCircle, Icon } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { fly } from 'svelte/transition'
import Comment from './Comment.svelte' import Comment from './Comment.svelte'
import Comments from './Comments.svelte' import Comments from './Comments.svelte'
import { buildCommentsTree, type CommentNodeI } from './comments.svelte' import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
import { errorMessage } from '$lib/lemmy/error'
interface Props { interface Props {
nodes: CommentNodeI[] nodes: CommentNodeI[]
@@ -103,7 +101,7 @@
} }
</script> </script>
<ul in:fly={{ duration: 500, easing: expoOut, y: -12, opacity: 0 }}> <ul>
{#each nodes as node, index (node.comment_view.comment.id)} {#each nodes as node, index (node.comment_view.comment.id)}
<Comment <Comment
postId={post.id} postId={post.id}
@@ -198,10 +198,11 @@
{#snippet item(row)} {#snippet item(row)}
<li <li
data-index={row} data-index={row}
style={row < 7 ? `--anim-delay: ${row * 100}ms` : ''} style={row < 7 ? `--anim-delay: ${row * 50}ms` : ''}
class="relative post-container {row < 7 class={[
? 'pop-in opacity-0' 'relative post-container px-4 sm:px-6',
: ''} px-4 sm:px-6" row < 7 && 'pop-in opacity-0',
]}
> >
<Post <Post
bind:post={posts[row]} bind:post={posts[row]}
@@ -288,7 +289,7 @@
} }
.pop-in { .pop-in {
animation: popIn 0.8s cubic-bezier(0.165, 0.84, 0.44, 1) forwards animation: popIn 0.5s cubic-bezier(0.165, 0.84, 0.44, 1) forwards
var(--anim-delay); var(--anim-delay);
} }
</style> </style>