diff --git a/src/components/Cell.vue b/src/components/Cell.vue index ced1d25..5f39c8b 100644 --- a/src/components/Cell.vue +++ b/src/components/Cell.vue @@ -76,7 +76,7 @@ const handlePointerCancel = (e) => { @pointerup="handlePointerUp" @pointercancel="handlePointerCancel" @pointerleave="handlePointerCancel" - @mouseenter="emit('enter-cell', props.r, props.c)" + @mouseenter="emit('enter-cell', props.r, props.c, $event)" @contextmenu.prevent > × diff --git a/src/components/GameBoard.vue b/src/components/GameBoard.vue index 2ce2b75..f43eef3 100644 --- a/src/components/GameBoard.vue +++ b/src/components/GameBoard.vue @@ -12,6 +12,9 @@ const { startDrag, onMouseEnter, stopDrag } = useNonogram(); const cellSize = ref(30); const rowHintsRef = ref(null); +const activeRow = ref(null); +const activeCol = ref(null); +const isFinePointer = ref(false); const getRowHintsWidth = () => { const el = rowHintsRef.value?.$el; @@ -52,10 +55,24 @@ const handlePointerMove = (e) => { } }; +const handleCellEnter = (r, c) => { + onMouseEnter(r, c); + if (!isFinePointer.value) return; + activeRow.value = r; + activeCol.value = c; +}; + +const handleGridLeave = () => { + stopDrag(); + activeRow.value = null; + activeCol.value = null; +}; + onMounted(() => { nextTick(() => { computeCellSize(); }); + isFinePointer.value = window.matchMedia('(pointer: fine)').matches; window.addEventListener('resize', computeCellSize); window.addEventListener('mouseup', handleGlobalMouseUp); window.addEventListener('pointerup', handleGlobalPointerUp); @@ -81,10 +98,10 @@ watch(() => store.size, async () => {
-