Compare commits

...

1 Commits

Author SHA1 Message Date
psychedelicious
f3ad2aed15 Revert "Update scaling math to land on 100% consistently."
This reverts commit 3fd28ce600.
2025-05-26 18:45:24 +10:00

View File

@@ -31,7 +31,7 @@ type CanvasStageModuleConfig = {
const DEFAULT_CONFIG: CanvasStageModuleConfig = {
MIN_SCALE: 0.1,
MAX_SCALE: 20,
SCALE_FACTOR: 0.9995,
SCALE_FACTOR: 0.999,
FIT_LAYERS_TO_STAGE_PADDING_PX: 48,
};
@@ -230,24 +230,7 @@ export class CanvasStageModule extends CanvasModuleBase {
* Constrains a scale to be within the valid range
*/
constrainScale = (scale: number): number => {
// Round to 2 decimal places to avoid floating point precision issues
const rounded = Math.round(scale * 100) / 100;
const clamped = clamp(rounded, this.config.MIN_SCALE, this.config.MAX_SCALE);
// Snap to 100% (scale = 1.0) with a more generous tolerance
if (Math.abs(clamped - 1) < 0.05) {
return 1;
}
// Snap to other common zoom levels for better UX
const commonScales = [0.25, 0.5, 0.75, 1.5, 2, 3, 4, 5];
for (const commonScale of commonScales) {
if (Math.abs(clamped - commonScale) < 0.03) {
return commonScale;
}
}
return clamped;
return clamp(Math.round(scale * 100) / 100, this.config.MIN_SCALE, this.config.MAX_SCALE);
};
/**