Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Spikeysanju committed Nov 10, 2024
1 parent 6321bd0 commit f2b43a7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
3 changes: 2 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
}))
);
async function handleDrop({ draggedItem, targetContainer }: DragDropState<Task>) {
async function handleDrop(state: DragDropState<Task>) {
const { draggedItem, targetContainer } = state;
if (!targetContainer) return; // Prevent self-placement
// Update the task's status to the target container
Expand Down
3 changes: 2 additions & 1 deletion src/routes/grid-sort/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
{ id: '6', color: 'from-pink-400 to-pink-600', icon: '🌸' }
]);
function handleDrop({ draggedItem, sourceContainer, targetContainer }: DragDropState<Card>) {
function handleDrop(state: DragDropState<Card>) {
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
Expand Down
3 changes: 2 additions & 1 deletion src/routes/horizontal-scroll/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
{ id: '4', url: 'https://picsum.photos/200/300?4' }
]);
function handleDrop({ draggedItem, sourceContainer, targetContainer }: DragDropState<ImageItem>) {
function handleDrop(state: DragDropState<ImageItem>) {
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
Expand Down
4 changes: 2 additions & 2 deletions src/routes/simple-list/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
}
]);
function handleDrop(state: DragDropState<unknown>) {
const { draggedItem, targetContainer } = state as DragDropState<Item>;
function handleDrop(state: DragDropState<Item>) {
const { draggedItem, targetContainer } = state;
const dragIndex = items.findIndex((item: Item) => item.id === draggedItem.id);
const dropIndex = parseInt(targetContainer ?? '0');
Expand Down

0 comments on commit f2b43a7

Please sign in to comment.