From 7342c18c00c9c39c24f21d4a89f3c1bbd4469d56 Mon Sep 17 00:00:00 2001 From: Dallas Hoffman Date: Tue, 17 Oct 2023 23:20:58 -0400 Subject: [PATCH] Add flip animation on note list --- src/lib/components/notes/note-list.svelte | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib/components/notes/note-list.svelte b/src/lib/components/notes/note-list.svelte index 4b31181..e5458f3 100644 --- a/src/lib/components/notes/note-list.svelte +++ b/src/lib/components/notes/note-list.svelte @@ -2,6 +2,7 @@ import NoteCard from '$lib/components/notes/note-card.svelte'; import { notes, settings } from '$lib/stores'; import { onDestroy, onMount } from 'svelte'; + import { flip } from 'svelte/animate'; import { get, type Unsubscriber } from 'svelte/store'; let noteListElement: HTMLUListElement; @@ -10,6 +11,7 @@ const paddingRows = 2; let scrollHeight = 0; let scrollOffset = 0; + let flipDuration = 0; let notesOffset = 0; let notesLimit = 100; @@ -37,6 +39,13 @@ Math.min(notesCount - offset, Math.ceil(windowHeight / rowHeight) + paddingRows * 2) * columnCount; + if (notesCount !== prevNotesCount) { + flipDuration = 300; + setTimeout(() => { + flipDuration = 0; + }, 300); + } + if ( offset === notesOffset && limit === notesLimit && @@ -80,7 +89,11 @@ style:--scroll-offset={`translateY(${scrollOffset}px)`} > {#each $notes as note (note.id)} -
  • +
  • {/each} @@ -97,11 +110,15 @@ padding: 0; margin: 0; - li { + &__item { list-style-type: none; margin: 0; transform: var(--scroll-offset, none); + &--no-flip { + animation: none !important; + } + &:has(.bytemd-fullscreen) { transform: none; }