Skip to content
Fluid DnD
Examples

Horizontal list on a scroller

SingleHorizontalListOfPokemonsAutoscroll.svelte
<script lang="ts">
import { useDragAndDrop } from "fluid-dnd/svelte";
import type { Pokemon } from "../Pokemon";
import PokemonComponent from "@/components/examples/svelte/PokemonComponent.svelte";
import { fetchPokemons } from "@/server/pokemonServer";
const pokemons = ([] as Pokemon[]);
fetchPokemons(9).then((newPokemons)=>{
pokemons.push(...newPokemons);
});
const [ parent ] = useDragAndDrop(pokemons, {
direction: "horizontal",
draggingClass: "dragging-pokemon",
});
</script>
<div class="flex max-sm:justify-center items-start">
<div
use:parent
class="bg-gray-200/60 border-solid border-black/40 rounded-2xl border-4 p-4 max-sm:p-2 flex flex-row overflow-auto gap-2 max-sm:gap-1"
>
{#each pokemons as pokemon, index (pokemon.name)}
<PokemonComponent
class="min-w-44 max-sm:min-w-32"
index={index}
pokemon={pokemon}
/>
{/each}
</div>
</div>