From 098a6d7e782e2ebe0fbb351763be10f2ff0e19ee Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Wed, 22 Oct 2025 09:58:47 +0200 Subject: [PATCH] disable zoom buttons on min/max zoom --- src/App/TopPanel.tsx | 9 +++++---- src/VisualEditor/parameters.ts | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/App/TopPanel.tsx b/src/App/TopPanel.tsx index 1e87514..623fae4 100644 --- a/src/App/TopPanel.tsx +++ b/src/App/TopPanel.tsx @@ -24,6 +24,7 @@ import { KeyInfoHidden, KeyInfoVisible } from "./KeyInfo"; import { About } from "./About"; import { usePersistentState } from "@/util/persistent_state"; import { RountangleIcon, PseudoStateIcon, HistoryIcon } from "./Icons"; +import { ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from "@/VisualEditor/parameters"; export type TopPanelProps = { rt?: BigStep, @@ -136,10 +137,10 @@ export function TopPanel({rt, rtIdx, time, setTime, onUndo, onRedo, onInit, onCl }, [time]); function onZoomIn() { - setZoom(zoom => Math.min(zoom * 1.25, (1.25)**6)); + setZoom(zoom => Math.min(zoom * ZOOM_STEP, ZOOM_MAX)); } function onZoomOut() { - setZoom(zoom => Math.max(zoom / 1.25, (1/1.25)**6)); + setZoom(zoom => Math.max(zoom / ZOOM_STEP, ZOOM_MIN)); } function onChangePaused(paused: boolean, wallclktime: number) { @@ -211,11 +212,11 @@ export function TopPanel({rt, rtIdx, time, setTime, onUndo, onRedo, onInit, onCl {/* zoom */}
Ctrl+-}> - + Ctrl++}> - +
diff --git a/src/VisualEditor/parameters.ts b/src/VisualEditor/parameters.ts index 6284f00..2a1f1e4 100644 --- a/src/VisualEditor/parameters.ts +++ b/src/VisualEditor/parameters.ts @@ -9,4 +9,9 @@ export const MIN_ROUNTANGLE_SIZE = { x: ROUNTANGLE_RADIUS*2, y: ROUNTANGLE_RADIU export const CORNER_HELPER_OFFSET = 4; export const CORNER_HELPER_RADIUS = 16; -export const HISTORY_RADIUS = 20; \ No newline at end of file +export const HISTORY_RADIUS = 20; + + +export const ZOOM_STEP = 1.25; +export const ZOOM_MIN = (1/ZOOM_STEP)**6; +export const ZOOM_MAX = ZOOM_STEP**6; \ No newline at end of file