| @@ -602,6 +602,11 @@ function hoveringInDeleteArea(e) { | |||||
| } | } | ||||
| function clickUp(e) { | function clickUp(e) { | ||||
| if (e.which != 1) { | |||||
| return; | |||||
| } | |||||
| clearTimeout(clickTimeout); | clearTimeout(clickTimeout); | ||||
| if (clicked) { | if (clicked) { | ||||
| @@ -1205,14 +1210,16 @@ function displayEntity(entity, view, x, y, selectEntity = false, refresh = false | |||||
| box.dataset.x = x; | box.dataset.x = x; | ||||
| box.dataset.y = y; | box.dataset.y = y; | ||||
| img.addEventListener("mousedown", e => { if (e.which == 1) { testClick(e); e.stopPropagation() } }); | |||||
| img.addEventListener("mousedown", e => { if (e.which == 1) { testClick(e); if (clicked) { e.stopPropagation() } } }); | |||||
| img.addEventListener("touchstart", e => { | img.addEventListener("touchstart", e => { | ||||
| const fakeEvent = { | const fakeEvent = { | ||||
| target: e.target, | target: e.target, | ||||
| clientX: e.touches[0].clientX, | clientX: e.touches[0].clientX, | ||||
| clientY: e.touches[0].clientY | |||||
| clientY: e.touches[0].clientY, | |||||
| which: 1 | |||||
| }; | }; | ||||
| testClick(fakeEvent); | testClick(fakeEvent); | ||||
| if (clicked) { e.stopPropagation() } | |||||
| }); | }); | ||||
| const heightBar = document.createElement("div"); | const heightBar = document.createElement("div"); | ||||
| @@ -1967,11 +1974,25 @@ document.addEventListener("DOMContentLoaded", () => { | |||||
| } | } | ||||
| }); | }); | ||||
| document.querySelector("#world").addEventListener("touchstart", e => { | |||||
| panning = true; | |||||
| panOffsetX = e.touches[0].clientX; | |||||
| panOffsetY = e.touches[0].clientY; | |||||
| e.preventDefault(); | |||||
| }); | |||||
| document.querySelector("#world").addEventListener("touchend", e => { | |||||
| panning = false; | |||||
| }); | |||||
| document.querySelector("body").appendChild(testCtx.canvas); | document.querySelector("body").appendChild(testCtx.canvas); | ||||
| updateSizes(); | updateSizes(); | ||||
| world.addEventListener("mousedown", e => deselect(e)); | world.addEventListener("mousedown", e => deselect(e)); | ||||
| world.addEventListener("touchstart", e => deselect({ | |||||
| which: 1, | |||||
| })); | |||||
| document.querySelector("#entities").addEventListener("mousedown", deselect); | document.querySelector("#entities").addEventListener("mousedown", deselect); | ||||
| document.querySelector("#display").addEventListener("mousedown", deselect); | document.querySelector("#display").addEventListener("mousedown", deselect); | ||||
| document.addEventListener("mouseup", e => clickUp(e)); | document.addEventListener("mouseup", e => clickUp(e)); | ||||
| @@ -1979,7 +2000,8 @@ document.addEventListener("DOMContentLoaded", () => { | |||||
| const fakeEvent = { | const fakeEvent = { | ||||
| target: e.target, | target: e.target, | ||||
| clientX: e.changedTouches[0].clientX, | clientX: e.changedTouches[0].clientX, | ||||
| clientY: e.changedTouches[0].clientY | |||||
| clientY: e.changedTouches[0].clientY, | |||||
| which: 1 | |||||
| }; | }; | ||||
| clickUp(fakeEvent); | clickUp(fakeEvent); | ||||
| }); | }); | ||||
| @@ -2060,14 +2082,14 @@ document.addEventListener("DOMContentLoaded", () => { | |||||
| }); | }); | ||||
| document.querySelector("#scroll-left").addEventListener("touchstart", e => { | document.querySelector("#scroll-left").addEventListener("touchstart", e => { | ||||
| scrollDirection = 1; | |||||
| scrollDirection = -1; | |||||
| clearInterval(scrollHandle); | clearInterval(scrollHandle); | ||||
| scrollHandle = setInterval(doXScroll, 1000 / 20); | scrollHandle = setInterval(doXScroll, 1000 / 20); | ||||
| e.stopPropagation(); | e.stopPropagation(); | ||||
| }); | }); | ||||
| document.querySelector("#scroll-right").addEventListener("touchstart", e => { | document.querySelector("#scroll-right").addEventListener("touchstart", e => { | ||||
| scrollDirection = -1; | |||||
| scrollDirection = 1; | |||||
| clearInterval(scrollHandle); | clearInterval(scrollHandle); | ||||
| scrollHandle = setInterval(doXScroll, 1000 / 20); | scrollHandle = setInterval(doXScroll, 1000 / 20); | ||||
| e.stopPropagation(); | e.stopPropagation(); | ||||
| @@ -2805,14 +2827,13 @@ document.addEventListener("mousemove", (e) => { | |||||
| document.querySelector("#menubar").classList.remove("hover-delete"); | document.querySelector("#menubar").classList.remove("hover-delete"); | ||||
| } | } | ||||
| } | } | ||||
| console.log(panning) | |||||
| if (panning && panReady) { | if (panning && panReady) { | ||||
| const worldWidth = config.height.toNumber("meters") / canvasHeight * canvasWidth; | const worldWidth = config.height.toNumber("meters") / canvasHeight * canvasWidth; | ||||
| const worldHeight = config.height.toNumber("meters"); | const worldHeight = config.height.toNumber("meters"); | ||||
| config.x += (e.clientX - panOffsetX) / canvasWidth * worldWidth; | |||||
| config.y -= (e.clientY - panOffsetY) / canvasHeight * worldHeight; | |||||
| config.x -= (e.clientX - panOffsetX) / canvasWidth * worldWidth; | |||||
| config.y += (e.clientY - panOffsetY) / canvasHeight * worldHeight; | |||||
| panOffsetX = e.clientX; | panOffsetX = e.clientX; | ||||
| panOffsetY = e.clientY; | panOffsetY = e.clientY; | ||||
| console.log(config.x, config.y) | console.log(config.x, config.y) | ||||
| @@ -2841,6 +2862,20 @@ document.addEventListener("touchmove", (e) => { | |||||
| document.querySelector("#menubar").classList.remove("hover-delete"); | document.querySelector("#menubar").classList.remove("hover-delete"); | ||||
| } | } | ||||
| } | } | ||||
| if (panning && panReady) { | |||||
| const worldWidth = config.height.toNumber("meters") / canvasHeight * canvasWidth; | |||||
| const worldHeight = config.height.toNumber("meters"); | |||||
| config.x -= (e.touches[0].clientX - panOffsetX) / canvasWidth * worldWidth; | |||||
| config.y += (e.touches[0].clientY - panOffsetY) / canvasHeight * worldHeight; | |||||
| panOffsetX = e.touches[0].clientX; | |||||
| panOffsetY = e.touches[0].clientY; | |||||
| console.log(config.x, config.y) | |||||
| updateSizes(); | |||||
| panReady = false; | |||||
| setTimeout(() => panReady=true, 50); | |||||
| } | |||||
| }, { passive: false }); | }, { passive: false }); | ||||
| function checkFitWorld() { | function checkFitWorld() { | ||||