mobile bug
This commit is contained in:
parent
6e4decfe5c
commit
441f8f6a09
@ -40,6 +40,7 @@
|
|||||||
<div
|
<div
|
||||||
v-for="(letter, i) in letters"
|
v-for="(letter, i) in letters"
|
||||||
:key="i"
|
:key="i"
|
||||||
|
:data-index="i"
|
||||||
class="absolute flex items-center justify-center bg-white text-indigo-700 rounded-full font-bold shadow-lg transition-all duration-200 active:scale-90 select-none"
|
class="absolute flex items-center justify-center bg-white text-indigo-700 rounded-full font-bold shadow-lg transition-all duration-200 active:scale-90 select-none"
|
||||||
:style="letterPosition(i)"
|
:style="letterPosition(i)"
|
||||||
:class="[
|
:class="[
|
||||||
@ -85,7 +86,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, nextTick, computed } from "vue";
|
import { ref, onMounted,onUnmounted, nextTick, computed } from "vue";
|
||||||
|
|
||||||
const allWords = [
|
const allWords = [
|
||||||
"TENANG", "SABAR", "SYUKUR", "CINTA", "GEMBIRA", "BANGGA",
|
"TENANG", "SABAR", "SYUKUR", "CINTA", "GEMBIRA", "BANGGA",
|
||||||
@ -164,6 +165,24 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mobile
|
||||||
|
function handleTouchMove(event) {
|
||||||
|
if (!isSelecting.value) return;
|
||||||
|
|
||||||
|
const touch = event.touches[0];
|
||||||
|
const element = document.elementFromPoint(touch.clientX, touch.clientY);
|
||||||
|
|
||||||
|
if (!element) return;
|
||||||
|
|
||||||
|
// Cek apakah elemen yang disentuh adalah salah satu huruf
|
||||||
|
const indexAttr = element.getAttribute("data-index");
|
||||||
|
if (indexAttr !== null) {
|
||||||
|
const i = parseInt(indexAttr);
|
||||||
|
dragSelect(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function startSelect(index) {
|
function startSelect(index) {
|
||||||
isSelecting.value = true;
|
isSelecting.value = true;
|
||||||
selectedIndexes.value = [index];
|
selectedIndexes.value = [index];
|
||||||
@ -251,6 +270,12 @@
|
|||||||
canvas.value.width = rect.width;
|
canvas.value.width = rect.width;
|
||||||
canvas.value.height = rect.height;
|
canvas.value.height = rect.height;
|
||||||
initGame();
|
initGame();
|
||||||
|
|
||||||
|
window.addEventListener("touchmove", handleTouchMove);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener("touchmove", handleTouchMove);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user