fix mouseenter detection

This commit is contained in:
Ilion Beyst 2022-08-28 16:28:15 +02:00
parent 0ce40a9f31
commit 0dbaf29d2f

View file

@ -110,7 +110,6 @@ export class Resizer {
this.orig_viewbox = [...this.viewbox]; 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("mouseleave", this.mouseleave.bind(this), { capture: false, passive: true});
el.addEventListener("mousemove", this.mousemove.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}); 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]; 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() { mouseleave() {
this.hoovering = false; this.hoovering = false;
} }
mousemove(e: MouseEvent) { 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]; this.mouse_pos = [e.offsetX, this.el_box[1] - e.offsetY];
if (this.dragging) { if (this.dragging) {