mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 05:24:06 +03:00
fix(Favorites): add a delay for dragging to allow touch to access tools
Fix #77
This commit is contained in:
1 parent
64ef495a3f
commit
bc8524d9d3
1 file changed
+20
-2
+20
-2
@@ -28,8 +28,24 @@ const { t } = useI18n();
|
|||||||
|
|
||||||
const favoriteTools = computed(() => toolStore.favoriteTools);
|
const favoriteTools = computed(() => toolStore.favoriteTools);
|
||||||
|
|
||||||
|
const isOrderingFavorites = ref(false);
|
||||||
|
|
||||||
|
window.oncontextmenu = (e) => {
|
||||||
|
if (isOrderingFavorites.value) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function startOrderingFavorites() {
|
||||||
|
isOrderingFavorites.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Update favorite tools order when drag is finished
|
// Update favorite tools order when drag is finished
|
||||||
function onUpdateFavoriteTools() {
|
function stopOrderingFavorites() {
|
||||||
|
isOrderingFavorites.value = false;
|
||||||
toolStore.updateFavoriteTools(favoriteTools.value); // Update the store with the new order
|
toolStore.updateFavoriteTools(favoriteTools.value); // Update the store with the new order
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +153,9 @@ onUnmounted(() => {
|
|||||||
class="grid grid-cols-1 gap-12px lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 xl:grid-cols-4"
|
class="grid grid-cols-1 gap-12px lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 xl:grid-cols-4"
|
||||||
ghost-class="ghost-favorites-draggable"
|
ghost-class="ghost-favorites-draggable"
|
||||||
item-key="name"
|
item-key="name"
|
||||||
@end="onUpdateFavoriteTools"
|
:delay="100"
|
||||||
|
@start="startOrderingFavorites"
|
||||||
|
@end="stopOrderingFavorites"
|
||||||
>
|
>
|
||||||
<template #item="{ element: tool }">
|
<template #item="{ element: tool }">
|
||||||
<ToolCard :tool="tool" />
|
<ToolCard :tool="tool" />
|
||||||
|
|||||||
Reference in new issue
Block a user