From 0dbaf29d2f6d06fe8fb7a4e0a2a2552484137f15 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sun, 28 Aug 2022 16:28:15 +0200 Subject: fix mouseenter detection --- web/pw-visualizer/src/webgl/util.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'web/pw-visualizer') 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) { -- cgit v1.2.3