Skip to content

Commit b4efb46

Browse files
committed
feat(site): add crossfade transitions to draggable items in nested and sortable examples
1 parent 303105a commit b4efb46

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

sites/docs/src/lib/components/examples/nested/draggable-containers.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import {SortableContext, arrayMove} from '@dnd-kit-svelte/sortable';
1414
import TasksContainer, {type IData, type INestedItem} from './tasks-container.svelte';
1515
import TaskItem from './task-item.svelte';
16+
import {crossfade} from 'svelte/transition';
1617
1718
const defaultItems: INestedItem[] = [
1819
{
@@ -122,6 +123,8 @@
122123
activeContainer.nesteds = activeContainer.nesteds.filter((nested) => nested.id !== active.id);
123124
overContainer.nesteds.push(item);
124125
}
126+
127+
const [send, recieve] = crossfade({duration: 250});
125128
</script>
126129

127130
<DndContext {sensors} onDragStart={handleDragStart} onDragEnd={handleDragEnd} onDragOver={handleDragOver}>
@@ -152,7 +155,9 @@
152155
<TasksContainer {data} type="container" accepts={['item']} class={className}>
153156
<SortableContext items={nesteds.map((item) => item.id)}>
154157
{#each nesteds as nested (nested.id)}
155-
<TaskItem data={nested} type="item" />
158+
<div class="" in:recieve={{key: nested.id}} out:send={{key: nested.id}}>
159+
<TaskItem data={nested} type="item" />
160+
</div>
156161
{:else}
157162
<p class="text-(sm center #9E9E9E) fw-medium pt">No tasks</p>
158163
{/each}

sites/docs/src/lib/components/examples/nested/tasks-container.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<div class="relative" bind:this={node.current} {style}>
4444
<!-- Original element - becomes invisible during drag but maintains dimensions -->
45-
<div class={['p-5 pt-6 bg-#F9F9F9 rd-3xl overflow-hidden', className, {invisible: isDragging.current}]}>
45+
<div class={['p-5 pt-6 bg-#F9F9F9 rd-3xl', className, {invisible: isDragging.current}]}>
4646
<div class="flex-s-between text-#9E9E9E">
4747
<div class="pl-5.5">
4848
<p class="text-(lg dark) fw-bold relative flex-s-start">

sites/docs/src/lib/components/examples/sortable/sortable-list.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
} from '@dnd-kit-svelte/core';
1111
import {SortableContext, arrayMove} from '@dnd-kit-svelte/sortable';
1212
import {dropAnimation, sensors} from '$lib';
13+
import {crossfade} from 'svelte/transition';
1314
1415
interface Todo {
1516
id: string;
@@ -72,6 +73,8 @@
7273
// Update the active task's done status to match the container it's being dragged over
7374
activeTask.done = overTask.done;
7475
}
76+
77+
const [send, recieve] = crossfade({duration: 100});
7578
</script>
7679

7780
<DndContext {sensors} onDragStart={handleDragStart} onDragEnd={handleDragEnd} onDragOver={handleDragOver}>
@@ -94,7 +97,9 @@
9497

9598
<div class="grid gap-2">
9699
{#each tasks as task (task.id)}
97-
<SortableItem {task} />
100+
<div class="" in:recieve={{key: task.id}} out:send={{key: task.id}}>
101+
<SortableItem {task} />
102+
</div>
98103
{/each}
99104
</div>
100105
</Droppable>

0 commit comments

Comments
 (0)