Skip to content

Commit 9320dd7

Browse files
Algorithm5838github-actions[bot]
authored andcommitted
perf: replace JS transition with CSS animation in TextToken
1 parent 8a874e1 commit 9320dd7

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
<script lang="ts">
2-
import { fade } from 'svelte/transition';
3-
42
export let token;
53
export let done = true;
6-
7-
let texts = [];
8-
$: texts = (token?.raw ?? '').split(' ');
94
</script>
105

116
{#if done}
127
{token?.raw}
138
{:else}
14-
{#each texts as text}
15-
<span class="" transition:fade={{ duration: 100 }}>
9+
{#each (token?.raw ?? '').split(' ') as text}
10+
<span class="fade-in-token">
1611
{text}{' '}
1712
</span>
1813
{/each}
1914
{/if}
15+
16+
<style>
17+
@keyframes fade-in-token {
18+
from {
19+
opacity: 0;
20+
}
21+
to {
22+
opacity: 1;
23+
}
24+
}
25+
.fade-in-token {
26+
animation: fade-in-token 100ms ease-out;
27+
}
28+
</style>

0 commit comments

Comments
 (0)