Skip to content

Commit

Permalink
add flip animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Spikeysanju committed Nov 10, 2024
1 parent 499470b commit 6321bd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/routes/grid-sort/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { draggable, droppable, type DragDropState } from '$lib/index.js';
import { flip } from 'svelte/animate';
interface Card {
id: string;
Expand Down Expand Up @@ -39,6 +40,7 @@
use:droppable={{ container: index.toString(), callbacks: { onDrop: handleDrop } }}
class="relative aspect-square rounded-xl bg-white/50 p-1 backdrop-blur-sm
transition-all duration-300 hover:bg-white/60 dark:bg-slate-800/50"
animate:flip={{ duration: 300 }}
>
<div
use:draggable={{
Expand Down
3 changes: 2 additions & 1 deletion src/routes/simple-list/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
}
]);
function handleDrop({ draggedItem, targetContainer }: DragDropState<Item>) {
function handleDrop(state: DragDropState<unknown>) {
const { draggedItem, targetContainer } = state as DragDropState<Item>;
const dragIndex = items.findIndex((item: Item) => item.id === draggedItem.id);
const dropIndex = parseInt(targetContainer ?? '0');
Expand Down

0 comments on commit 6321bd0

Please sign in to comment.