diff options
| author | julian laplace <julescarbon@gmail.com> | 2025-07-07 21:01:13 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2025-07-07 21:01:13 +0200 |
| commit | 21b0b98d988be30852254e2977c8042f23b15252 (patch) | |
| tree | 99069aad0a81f6d3193e5e7b2780ac973df6500c /client | |
| parent | dfbd36be4341f633cb51d187d3245efbc9d500a8 (diff) | |
mousewheel
Diffstat (limited to 'client')
| -rw-r--r-- | client/index.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/client/index.js b/client/index.js index df127e4..4ca290b 100644 --- a/client/index.js +++ b/client/index.js @@ -65,7 +65,7 @@ function build() { hs = Math.ceil(h / s); const scale = scales[scaleMode % scales.length]; if (scale.reset) { - scale.reset(base_x, base_y, ws, hs); + scale.reset(Math.round(base_x), Math.round(base_y), ws, hs); } for (var i = 0; i < ws; i++) { notes[i] = []; @@ -143,11 +143,18 @@ function toggle(note) { } function add(i, j) { - const ii = i + base_x; - const jj = j + base_y; + const ii = i + Math.round(base_x); + const jj = j + Math.round(base_y); const scale = scales[scaleMode % scales.length]; - const [a, b] = scale.get(ii, jj, i, j, base_x, base_y); + const [a, b] = scale.get( + ii, + jj, + i, + j, + Math.round(base_x), + Math.round(base_y), + ); const div = document.createElement("div"); const interval = a / b; @@ -299,6 +306,21 @@ function bind() { .addEventListener("click", () => document.querySelector("#help").classList.toggle("visible"), ); + grid.addEventListener("wheel", (e) => { + const new_base_x = Math.max(0, base_x + e.deltaX / 32); + const new_base_y = Math.max(0, base_y + e.deltaY / 32); + if ( + Math.round(base_x) !== Math.round(new_base_x) || + Math.round(base_y) !== Math.round(new_base_y) + ) { + base_x = new_base_x; + base_y = new_base_y; + rebuild(); + } else { + base_x = new_base_x; + base_y = new_base_y; + } + }); } let isReset = false; |
