Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
noxware committed Sep 13, 2024
1 parent 3757c48 commit 16ab606
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions companion-js-app/companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function App() {
};

// Because of the svg having no pointer events, only the canvas can read mousemove, document, window and body can't, idk why.
// And this will not trigger if canvas is nor receving mousemove events.
document
.getElementById("the_canvas_id")
.addEventListener("mousemove", handleMouseMove);
Expand All @@ -85,9 +86,7 @@ function App() {
.removeEventListener("mousemove", handleMouseMove);
}, []);

const htmlAreas = areas.filter((area) => area.kind === "html");

const hoveredHtmlArea = htmlAreas.findLast((area) => {
const hoveredArea = areas.findLast((area) => {
return (
area.x <= mouseX &&
mouseX <= area.x + area.width &&
Expand All @@ -96,7 +95,7 @@ function App() {
);
});
console.log(mouseX, mouseY);
console.log(hoveredHtmlArea);
console.log(hoveredArea);

return h(
"svg",
Expand Down Expand Up @@ -124,9 +123,9 @@ function App() {
),
]),

htmlAreas.map((area) =>
Area({ area, interactive: area === hoveredHtmlArea })
),
areas
.filter((area) => area.kind === "html")
.map((area) => Area({ area, interactive: area === hoveredArea })),
]
);
}
Expand Down

0 comments on commit 16ab606

Please sign in to comment.