Skip to content

Commit c0898c0

Browse files
committed
🐞 fix: make delayBeforeTouchMoveEvent config optional
1 parent 1d9387f commit c0898c0

File tree

6 files changed

+74
-22
lines changed

6 files changed

+74
-22
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@types/react": "^19.1.2",
2222
"@types/react-dom": "^19.1.3",
2323
"astro": "^5.6.1",
24-
"fluid-dnd": "^2.0.2",
24+
"fluid-dnd": "^2.1.0",
2525
"react": "^19.1.0",
2626
"react-dom": "^19.1.0",
2727
"sharp": "^0.34.1",

docs/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/components/examples/vue/SingleVerticalListOfPokemons.vue

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
<script setup lang="ts">
2-
import { ref } from "vue";
2+
import { ref, watchEffect } from "vue";
33
import { useDragAndDrop } from "fluid-dnd/vue";
44
import type { Pokemon } from "../Pokemon";
55
import PokemonComponent from "./PokemonComponent.vue";
66
import { fetchPokemons } from "@/server/pokemonServer";
7+
import touchDelaySilder from "./touchDelaySilder.vue";
78
89
const pokemons = ref([] as Pokemon[]);
910
pokemons.value = await fetchPokemons(3);
10-
const [ parent ] = useDragAndDrop(pokemons, {
11-
draggingClass: "dragging-pokemon",
12-
});
11+
const delay = ref(150);
12+
let parent = ref<HTMLElement | undefined>();
13+
14+
watchEffect(()=>{
15+
const dragAndDrop = useDragAndDrop(pokemons, {
16+
draggingClass: "dragging-pokemon",
17+
delayBeforeTouchMoveEvent: delay.value,
18+
});
19+
parent = dragAndDrop[0];
20+
})
1321
</script>
1422
<template>
15-
<div class="flex max-sm:justify-center items-start">
16-
<div
17-
ref="parent"
18-
class="bg-gray-200/60 border-solid border-black/40 rounded-2xl w-60 border-4 p-4 block"
19-
>
20-
<PokemonComponent
21-
v-for="(pokemon, index) in pokemons"
22-
:key="pokemon.name"
23-
:index="index"
24-
:pokemon="pokemon"
25-
/>
23+
<div class="flex-col gap-4">
24+
<div class="flex max-sm:justify-center items-start">
25+
<div
26+
ref="parent"
27+
class="bg-gray-200/60 border-solid border-black/40 rounded-2xl w-60 border-4 p-4 block"
28+
>
29+
<PokemonComponent
30+
v-for="(pokemon, index) in pokemons"
31+
:key="pokemon.name"
32+
:index="index"
33+
:pokemon="pokemon"
34+
/>
35+
</div>
2636
</div>
37+
<touchDelaySilder v-model="delay"/>
2738
</div>
2839
</template>
2940
<style>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<template>
2+
<div class="flex flex-col gap-8 delay-menu">
3+
<h2>Delay before touchmove event</h2>
4+
<div class="w-full max-w-xs">
5+
<input type="range" min="150" max="750" value="150" class="range w-full" step="150" @change="changeDelay" />
6+
<div class="flex justify-between px-2.5 mt-2 text-xs">
7+
<span>|</span>
8+
<span>|</span>
9+
<span>|</span>
10+
<span>|</span>
11+
<span>|</span>
12+
</div>
13+
<div class="flex justify-between mt-2 text-xs">
14+
<span>150</span>
15+
<span>300</span>
16+
<span>450</span>
17+
<span>600</span>
18+
<span>750</span>
19+
</div>
20+
</div>
21+
</div>
22+
</template>
23+
24+
<script setup lang="ts">
25+
const model = defineModel({ type: Number })
26+
const emit = defineEmits<{
27+
(e: 'update:modelValue', value: Number | number): void
28+
}>();
29+
const changeDelay = (event: Event) => {
30+
const target = event.target as HTMLInputElement;
31+
const value = parseFloat(target.value); // Convert string to number
32+
emit('update:modelValue', value);
33+
}
34+
</script>
35+
<style scoped>
36+
.delay-menu {
37+
margin-top: 3rem !important;
38+
}
39+
</style>

docs/src/tailwind.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
/* @plugin "daisyui"; */
5+
46
details {
57
max-height: 4rem; /* Set a max-height value just enough to show the summary */
68
overflow: hidden; /* Hide the rest of the content */

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export interface DragStartEventData<T> {
9090
/**
9191
* The delay before the touchmove event is fired.
9292
*/
93-
delayBeforeTouchMoveEvent:number;
93+
delayBeforeTouchMoveEvent?:number;
9494
}
9595
/**
9696
* onDrop event function.

0 commit comments

Comments
 (0)