diff --git a/public/views/grid-setup.mjs b/public/views/grid-setup.mjs index 9c39817..3eb0078 100644 --- a/public/views/grid-setup.mjs +++ b/public/views/grid-setup.mjs @@ -29,7 +29,7 @@ export class Grid_Setup { this.#canvas = canvas_el; this.#ctx = canvas_el.getContext('2d'); - canvas_el.addEventListener('mousedown', e => this.#on_down(e)); + canvas_el.addEventListener('mousedown', e => { e.preventDefault(); this.#on_down(e); }); canvas_el.addEventListener('mousemove', e => this.#on_move(e)); canvas_el.addEventListener('mouseup', e => this.#on_up(e)); canvas_el.addEventListener('mouseleave', () => { this.#drag_idx = -1; this.#panning = false; }); @@ -161,14 +161,19 @@ export class Grid_Setup { #on_down(e, is_touch = false) { if (!this.#corners) return; const sp = this.#screen_pos(e); + if (!is_touch && e.button === 1) { + // Middle button: pan + e.preventDefault(); + this.#panning = true; + this.#pan_last = sp; + this.#canvas.style.cursor = 'grabbing'; + return; + } + if (!is_touch && e.button !== 0) { return; } const hit = this.#find_handle(sp); if (hit !== -1) { this.#drag_idx = hit; this.#drag_prev_img = this.#world_to_img(this.#to_world(sp)); - } else { - this.#panning = true; - this.#pan_last = sp; - if (!is_touch) { this.#canvas.style.cursor = 'grabbing'; } } }