draggable / touchable card v0.1
All checks were successful
Deploy App / build (push) Successful in 1m53s
Deploy App / deploy (push) Successful in 18s

This commit is contained in:
valere
2025-12-24 06:00:15 +01:00
parent 1f4f7868ca
commit ad938abf79
11 changed files with 414 additions and 201 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="bucket" :class="{ 'drag-over': isDragOver }" @dragenter.prevent="onDragEnter"
<div class="bucket" ref="bucket" :class="{ 'drag-over': isDragOver }" @dragenter.prevent="onDragEnter"
@dragover.prevent="onDragOver" @dragleave="onDragLeave" @drop.prevent="onDrop">
<div v-if="tracks.length === 0" class="bucket-empty">
Drop cards here
@@ -14,10 +14,14 @@
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { ref, watch, defineEmits, onMounted } from 'vue'
import draggable from 'vuedraggable'
import { useDataStore } from '~/store/data'
const emit = defineEmits<{
(e: 'card-dropped', track: any): void
}>()
const props = defineProps<{
modelValue?: any[]
boxId?: string
@@ -27,6 +31,7 @@ const dataStore = useDataStore()
const isDragOver = ref(false)
const drag = ref(false)
const tracks = ref<any[]>(props.modelValue || [])
const bucket = ref()
watch(() => props.modelValue, (newValue) => {
if (newValue) {
@@ -37,7 +42,9 @@ watch(() => props.modelValue, (newValue) => {
if (props.boxId) {
onMounted(async () => {
await dataStore.loadData()
tracks.value = dataStore.getTracksByboxId(props.boxId)
if (props.boxId) {
tracks.value = dataStore.getTracksByboxId(props.boxId)
}
})
}
@@ -83,6 +90,13 @@ const onDrop = (e: DragEvent) => {
const flipCard = (track: any) => {
track.isFaceUp = !track.isFaceUp
}
onMounted(() => {
// Écouter aussi les événements tactiles personnalisés
bucket.value?.addEventListener('card-dropped-touch', (e: CustomEvent) => {
emit('card-dropped', e.detail)
})
})
</script>
<style scoped>