Przeglądaj źródła

Fix selection and menu not turning red when hovering with touch controls

tags/v0.0.2^0
Fen Dweller 5 lat temu
rodzic
commit
0be141f8c8
1 zmienionych plików z 14 dodań i 3 usunięć
  1. +14
    -3
      macrovision.js

+ 14
- 3
macrovision.js Wyświetl plik

@@ -572,16 +572,17 @@ document.addEventListener("DOMContentLoaded", () => {
})

document.querySelector("#options-height-unit").addEventListener("input", e => {
updateWorldHeight();
updateWorldHeight();
})

world.addEventListener("mousedown", e => deselect());
document.addEventListener("mouseup", e => clickUp(e));
document.addEventListener("touchend", e => {
console.log(e)
const fakeEvent = {
target: e.target,
clientX: e.touches[0].clientX,
clientY: e.touches[0].clientY
clientX: e.changedTouches[0].clientX,
clientY: e.changedTouches[0].clientY
};
clickUp(fakeEvent);});

@@ -655,10 +656,20 @@ document.addEventListener("touchmove", (e) => {
let x = e.touches[0].clientX;
let y = e.touches[0].clientY;

console.log(y)

const position = snapRel(abs2rel({ x: x - dragOffsetX, y: y - dragOffsetY }));
clicked.dataset.x = position.x;
clicked.dataset.y = position.y;
updateEntityElement(entities[clicked.dataset.key], clicked);

// what a hack
// I should centralize this 'fake event' creation...
if (hoveringInDeleteArea({clientY: y})) {
document.querySelector("#menubar").classList.add("hover-delete");
} else {
document.querySelector("#menubar").classList.remove("hover-delete");
}
}
}, {passive: false});



Ładowanie…
Anuluj
Zapisz