aboutsummaryrefslogtreecommitdiff
path: root/web/pw-visualizer/src/webgl
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-08-28 16:28:15 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-08-28 16:28:15 +0200
commit0dbaf29d2f6d06fe8fb7a4e0a2a2552484137f15 (patch)
tree408fd9c8ee6b98e7a3c91753d84a8fdeeb845a76 /web/pw-visualizer/src/webgl
parent0ce40a9f317ed243a0c97141bc4e9af85b39f439 (diff)
downloadplanetwars.dev-0dbaf29d2f6d06fe8fb7a4e0a2a2552484137f15.tar.xz
planetwars.dev-0dbaf29d2f6d06fe8fb7a4e0a2a2552484137f15.zip
fix mouseenter detection
Diffstat (limited to 'web/pw-visualizer/src/webgl')
-rw-r--r--web/pw-visualizer/src/webgl/util.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/web/pw-visualizer/src/webgl/util.ts b/web/pw-visualizer/src/webgl/util.ts
index e08af3f..0a93d67 100644
--- a/web/pw-visualizer/src/webgl/util.ts
+++ b/web/pw-visualizer/src/webgl/util.ts
@@ -110,7 +110,6 @@ export class Resizer {
this.orig_viewbox = [...this.viewbox];
- el.addEventListener("mouseenter", this.mouseenter.bind(this), { capture: false, passive: true});
el.addEventListener("mouseleave", this.mouseleave.bind(this), { capture: false, passive: true});
el.addEventListener("mousemove", this.mousemove.bind(this), { capture: false, passive: true});
el.addEventListener("mousedown", this.mousedown.bind(this), { capture: false, passive: true});
@@ -127,15 +126,14 @@ export class Resizer {
this.viewbox[1] = Math.min(this.viewbox[1] + this.viewbox[3], this.orig_viewbox[1] + this.orig_viewbox[3]) - this.viewbox[3];
}
- mouseenter() {
- this.hoovering = true;
- }
-
mouseleave() {
this.hoovering = false;
}
mousemove(e: MouseEvent) {
+ // when using mouseenter, hooveing will not be set to true if the mouse is already on the element when it is being created.
+ // TODO: is there a better way?
+ this.hoovering = true;
this.mouse_pos = [e.offsetX, this.el_box[1] - e.offsetY];
if (this.dragging) {