Make zoom hotkeys zoom towards cursor

This commit is contained in:
Simon Lydell 2024-04-28 14:24:01 +02:00
parent c99bb2122d
commit d9c6a3b0e0

View File

@ -208,11 +208,17 @@ export class Editor extends PrimaryView {
}
}
else if (ev.key === '-') {
if (this.mouse_coords)
this.zoom_by(-1, this.mouse_coords[0], this.mouse_coords[1]);
else
this.zoom_by(-1);
}
// `=` because US keyboards have `+` on the same key as `=`, and `+` is shift-`=`
// `+` because many other keyboards have `+` on its own key, un-shifted, while `=` is shifted
else if (ev.key === '=' || ev.key === '+') {
if (this.mouse_coords)
this.zoom_by(+1, this.mouse_coords[0], this.mouse_coords[1]);
else
this.zoom_by(+1);
}
else if (ev.key === '1') {