clamp zoom also in extension.js

This commit is contained in:
HF 2024-01-21 23:39:07 +01:00
parent f20f5852aa
commit 91f62407bf

View File

@ -34,16 +34,17 @@ function monkeyPatchRenderer(renderer) {
const [x, y, scale] = this._view; const [x, y, scale] = this._view;
if (x !== px || y !== py) { if (x !== px || y !== py) {
/* /*
* view: [x, y] float canvas coordinates of the center of the screen, * [x, y]: floats of canvas coordinates of the center of the screen,
*/ */
pixelPlanetEvents.emit('setviewcoordinates', [x, y]); pixelPlanetEvents.emit('setviewcoordinates', [x, y]);
} }
if (scale !== pScale) { if (scale !== pScale) {
// clamp to 1 if origin is given, see src/ui/Renderer2.js#184
const viewscale = (args[1] && scale > 0.85 && scale < 1.20) ? 1.0 : scale;
/* /*
* scale: float of canvas scale aka zoom * viewscale: float of canvas scale aka zoom
* (not logarithmic, doesn't clamp to 1.0)
*/ */
pixelPlanetEvents.emit('setscale', scale); pixelPlanetEvents.emit('setscale', viewscale);
} }
}; };
} }