Skip to content

Commit

Permalink
Unify style of enum definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Davis committed Apr 28, 2024
1 parent 19c6bc6 commit 02265a9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions src/core/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const ZOOM_SCALE_STEPS = [0.1, 0.15, 0.25, 0.33, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0,
const ZOOM_TO_FIT_PADDING = 0.15; // 15%

export enum PanDirection {
Up = "Up",
Right = "Right",
Down = "Down",
Left = "Left",
up,
right,
down,
left,
}

export enum ZoomDirection {
In,
Out,
in,
out,
}

export class Layout {
Expand Down Expand Up @@ -94,7 +94,7 @@ export class Layout {
}

public zoomByStep(direction: ZoomDirection): number {
const isZoomOut = direction === ZoomDirection.Out;
const isZoomOut = direction === ZoomDirection.out;
const increment = isZoomOut ? -1 : 1;
const lastStepIndex = ZOOM_SCALE_STEPS.length - 1;

Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const appStore = new AppStore(world, layoutStore, playbackStore);
const pluginBuilder = new PluginBuilder(canvas);
const pluginManager = new PluginManager(pluginBuilder, layoutStore, playbackStore, appStore);

pluginManager.activateGroup(PluginGroup.Default);
pluginManager.activateGroup(PluginGroup.Playback);
pluginManager.activateGroup(PluginGroup.default);
pluginManager.activateGroup(PluginGroup.playback);

const app = document.createElement("x-app");

Expand Down
20 changes: 10 additions & 10 deletions src/plugins/PluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { LayoutStore } from "../stores/LayoutStore";
import { PlaybackStore } from "../stores/PlaybackStore";

export enum PluginGroup {
Default = "Default",
Playback = "Playback",
default,
playback,
}

export class PluginManager {
Expand All @@ -27,21 +27,21 @@ export class PluginManager {
this._playbackStore = playbackStore;
this._appStore = appStore;

this._pluginGroups.set(PluginGroup.Default, [
this._pluginGroups.set(PluginGroup.default, [
new ResizePlugin(this._layoutStore.fitCanvasToWindow),
new WheelPlugin(this._layoutStore.zoomAt),
new KeyboardPlugin("mod+=", () => this._layoutStore.zoomByStep(ZoomDirection.In)),
new KeyboardPlugin("mod+-", () => this._layoutStore.zoomByStep(ZoomDirection.Out)),
new KeyboardPlugin("mod+=", () => this._layoutStore.zoomByStep(ZoomDirection.in)),
new KeyboardPlugin("mod+-", () => this._layoutStore.zoomByStep(ZoomDirection.out)),
new KeyboardPlugin("mod+1", () => this._layoutStore.zoomToScale(1)),
new KeyboardPlugin("mod+2", () => this._layoutStore.zoomToScale(2)),
new KeyboardPlugin("mod+0", () => this._layoutStore.zoomToFit()),
new KeyboardPlugin("ArrowUp", () => this._layoutStore.panInDirection(PanDirection.Up)),
new KeyboardPlugin("ArrowRight", () => this._layoutStore.panInDirection(PanDirection.Right)),
new KeyboardPlugin("ArrowDown", () => this._layoutStore.panInDirection(PanDirection.Down)),
new KeyboardPlugin("ArrowLeft", () => this._layoutStore.panInDirection(PanDirection.Left)),
new KeyboardPlugin("ArrowUp", () => this._layoutStore.panInDirection(PanDirection.up)),
new KeyboardPlugin("ArrowRight", () => this._layoutStore.panInDirection(PanDirection.right)),
new KeyboardPlugin("ArrowDown", () => this._layoutStore.panInDirection(PanDirection.down)),
new KeyboardPlugin("ArrowLeft", () => this._layoutStore.panInDirection(PanDirection.left)),
]);

this._pluginGroups.set(PluginGroup.Playback, [
this._pluginGroups.set(PluginGroup.playback, [
new DragPlugin((_x, _y, deltaX, deltaY) => this._layoutStore.translateOffset(deltaX, deltaY), {
cursor: "move",
}),
Expand Down
8 changes: 4 additions & 4 deletions src/stores/LayoutStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ export class LayoutStore {
let deltaY = 0;

switch (direction) {
case PanDirection.Up:
case PanDirection.up:
deltaY += panIncrement;
break;
case PanDirection.Right:
case PanDirection.right:
deltaX -= panIncrement;
break;
case PanDirection.Down:
case PanDirection.down:
deltaY -= panIncrement;
break;
case PanDirection.Left:
case PanDirection.left:
deltaX += panIncrement;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/x-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ class App extends MobxLitElement {
const value = (e.target as Menu).value;

if (value === "in") {
this.layoutStore.zoomByStep(ZoomDirection.In);
this.layoutStore.zoomByStep(ZoomDirection.in);
return;
}

if (value === "out") {
this.layoutStore.zoomByStep(ZoomDirection.Out);
this.layoutStore.zoomByStep(ZoomDirection.out);
return;
}

Expand Down

0 comments on commit 02265a9

Please sign in to comment.