Skip to content

Commit

Permalink
Simplify action style for setting zoomScale
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Davis committed Sep 30, 2024
1 parent 46204bf commit 9a594d5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/stores/LayoutStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeObservable, observable, runInAction } from "mobx";
import { makeObservable, observable, action } from "mobx";
import { PIXEL_RATIO, NATURAL_CELL_SIZE, SIDEBAR_WIDTH } from "../Constants";
import { Layout, PanDirection, ZoomDirection } from "../core/Layout";
import { Renderer } from "../core/Renderer";
Expand Down Expand Up @@ -28,13 +28,12 @@ export class LayoutStore {
this.fitCanvasToWindow();
}

@action
private _setZoomScaleTruncated(zoomScale: number): void {
// Multiply by 100 and truncate number to two decimal places for nicer UI
const zoomScaleTruncated = Math.round((zoomScale + Number.EPSILON) * 100);

runInAction(() => {
this.zoomScale = zoomScaleTruncated;
});
this.zoomScale = zoomScaleTruncated;
}

public zoomToScale(scale: number): void {
Expand Down

0 comments on commit 9a594d5

Please sign in to comment.