Browse Source

Fix selection not working on Firefox

For whatever reason, I cannot seem to draw an SVG to a canvas.
Therefore, the selection test function does not work.
The current solution is to just skip the logic in Firefox and
use the standard bounding-box selection.
tags/v0.0.3
Fen Dweller 5 years ago
parent
commit
bd0b61c745
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      macrovision.js

+ 10
- 1
macrovision.js View File

@@ -467,7 +467,14 @@ testCanvas.id = "test-canvas";

const testCtx = testCanvas.getContext("2d");
function testClick(event) {

// oh my god I can't believe I'm doing this

const target = event.target;
if (navigator.userAgent.indexOf("Firefox") != -1) {
clickDown(target.parentElement, event.clientX, event.clientY);
}
// Get click coordinates

let w = target.width;
@@ -504,7 +511,6 @@ function testClick(event) {
const oldDisplay = target.style.display;
target.style.display = "none";
const newTarget = document.elementFromPoint(event.clientX, event.clientY);
console.log(newTarget);
newTarget.dispatchEvent(new MouseEvent(event.type, {
"clientX": event.clientX,
"clientY": event.clientY
@@ -544,6 +550,9 @@ function displayEntity(entity, view, x, y) {

const img = document.createElement("img");
img.classList.add("entity-image");
img.addEventListener("dragstart", e => {
e.preventDefault();
});
const nameTag = document.createElement("div");
nameTag.classList.add("entity-name");
nameTag.innerText = entity.name;


Loading…
Cancel
Save