From f2b43a7cd06f284d05e2e5d97c552b8ab94d4a44 Mon Sep 17 00:00:00 2001 From: SpikeySanju Date: Sun, 10 Nov 2024 19:49:00 +0530 Subject: [PATCH] update readme --- README.md | 1 + src/routes/+page.svelte | 3 ++- src/routes/grid-sort/+page.svelte | 3 ++- src/routes/horizontal-scroll/+page.svelte | 3 ++- src/routes/simple-list/+page.svelte | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b5e5f21..7a00726 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ function handleDrop(state: DragDropState<{ id: string }>) { const { draggedItem, sourceContainer, targetContainer } = state; if (!targetContainer || sourceContainer === targetContainer) return; + // Update items based on the drop items = items.filter((item) => item !== draggedItem); items = [...items, draggedItem]; } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 2392f25..b9a59b3 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -59,7 +59,8 @@ })) ); - async function handleDrop({ draggedItem, targetContainer }: DragDropState) { + async function handleDrop(state: DragDropState) { + const { draggedItem, targetContainer } = state; if (!targetContainer) return; // Prevent self-placement // Update the task's status to the target container diff --git a/src/routes/grid-sort/+page.svelte b/src/routes/grid-sort/+page.svelte index 4d06a34..781b04b 100644 --- a/src/routes/grid-sort/+page.svelte +++ b/src/routes/grid-sort/+page.svelte @@ -17,7 +17,8 @@ { id: '6', color: 'from-pink-400 to-pink-600', icon: '🌸' } ]); - function handleDrop({ draggedItem, sourceContainer, targetContainer }: DragDropState) { + function handleDrop(state: DragDropState) { + const { draggedItem, sourceContainer, targetContainer } = state; if (!targetContainer || sourceContainer === targetContainer) return; // Prevent self-placement cards = cards.filter((card: Card) => card.id !== draggedItem.id); // Remove the dragged item diff --git a/src/routes/horizontal-scroll/+page.svelte b/src/routes/horizontal-scroll/+page.svelte index 0b1f8d5..c66ba54 100644 --- a/src/routes/horizontal-scroll/+page.svelte +++ b/src/routes/horizontal-scroll/+page.svelte @@ -14,7 +14,8 @@ { id: '4', url: 'https://picsum.photos/200/300?4' } ]); - function handleDrop({ draggedItem, sourceContainer, targetContainer }: DragDropState) { + function handleDrop(state: DragDropState) { + const { draggedItem, sourceContainer, targetContainer } = state; if (!targetContainer || sourceContainer === targetContainer) return; // Prevent self-placement images = images.filter((img: ImageItem) => img.id !== draggedItem.id); // Remove the dragged item diff --git a/src/routes/simple-list/+page.svelte b/src/routes/simple-list/+page.svelte index 6757dab..211e421 100644 --- a/src/routes/simple-list/+page.svelte +++ b/src/routes/simple-list/+page.svelte @@ -31,8 +31,8 @@ } ]); - function handleDrop(state: DragDropState) { - const { draggedItem, targetContainer } = state as DragDropState; + function handleDrop(state: DragDropState) { + const { draggedItem, targetContainer } = state; const dragIndex = items.findIndex((item: Item) => item.id === draggedItem.id); const dropIndex = parseInt(targetContainer ?? '0');