On this Page
ReorderTransferDetail
ReorderTransferDetail<T> describes an item that has been transferred into a compatible ReorderGroup. It is the payload passed to the receiving group’s ontransfer callback and is a TypeScript interface, not a rendered component.
Usage
Svelte
<script lang="ts">
import {
ReorderGroup,
ReorderItem,
type ReorderTransferDetail
} from 'fractalsvelte/motion';
type Task = { id: string; label: string };
let backlog = $state<Task[]>([{ id: 'research', label: 'Research' }]);
let inProgress = $state<Task[]>([]);
let lastTransfer = $state<ReorderTransferDetail<Task> | undefined>();
</script>
<ReorderGroup bind:values={backlog} id="backlog" group="tasks">
{#each backlog as task (task.id)}
<ReorderItem value={task}>{task.label}</ReorderItem>
{/each}
</ReorderGroup>
<ReorderGroup
bind:values={inProgress}
id="in-progress"
group="tasks"
ontransfer={(detail) => (lastTransfer = detail)}
>
{#each inProgress as task (task.id)}
<ReorderItem value={task}>{task.label}</ReorderItem>
{/each}
</ReorderGroup>
{#if lastTransfer}
<p>{lastTransfer.value.label} moved from {lastTransfer.from} to {lastTransfer.to}.</p>
{/if}
Matching group values enable pointer transfer between lists. The destination group emits ontransfer after it has inserted the value into its bound values array.
API
TypeScript
interface ReorderTransferDetail<T = unknown> {
value: T;
from?: string;
to: string;
index: number;
}
| Field | Type | Description |
|---|---|---|
value | T | The item moved into the receiving group. |
from | string \| undefined | The source group’s id, when one is available. |
to | string | The receiving group’s id. |
index | number | Zero-based insertion index in the receiving group. |
Related APIs
- Use
Reorderfor the completeReorderGroupandReorderIteminteraction model. ReorderGroupacceptsontransfer?: (detail: ReorderTransferDetail<T>) => void.- Use
id,group, andacceptsonReorderGroupto identify compatible source and destination collections.
