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