Skip to content

Commit

Permalink
chore: set multiplier to 2 and max zoom to 120%
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsojramos committed Jul 1, 2024
1 parent bb00f1a commit c86e7fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/components/settings/AppearanceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export const AppearanceSettings: FC = () => {
<Slider
defaultValue={[zoomLevel]}
value={[zoomLevel]}
max={150}
max={120}
min={0}
step={25}
step={20}
name="Zoom"
onValueChange={(value) =>
webFrame.setZoomLevel(percentageToZoom(value[0]))
Expand Down
6 changes: 3 additions & 3 deletions src/routes/__snapshots__/Settings.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/utils/zoom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { percentageToZoom, zoomToPercentage } from './zoom';
describe('utils/zoom.ts', () => {
it('should convert percentage to zoom level', () => {
expect(percentageToZoom(100)).toBe(0);
expect(percentageToZoom(50)).toBe(-0.925);
expect(percentageToZoom(0)).toBe(-1.85);
expect(percentageToZoom(150)).toBe(0.925);
expect(percentageToZoom(50)).toBe(-1);
expect(percentageToZoom(0)).toBe(-2);
expect(percentageToZoom(150)).toBe(1);
});

it('should convert zoom level to percentage', () => {
expect(zoomToPercentage(0)).toBe(100);
expect(zoomToPercentage(-1)).toBe(46);
expect(zoomToPercentage(-2)).toBe(-8);
expect(zoomToPercentage(1)).toBe(154);
expect(zoomToPercentage(-1)).toBe(50);
expect(zoomToPercentage(-2)).toBe(0);
expect(zoomToPercentage(1)).toBe(150);
});
});
4 changes: 2 additions & 2 deletions src/utils/zoom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const RECOMMENDED = 100;
const MULTIPLIER = 1.85;
const MULTIPLIER = 2;

/**
* Percentage to zoom level. 100% is the recommended zoom level (0).
Expand All @@ -11,5 +11,5 @@ export const percentageToZoom = (percentage: number): number => {
};

export const zoomToPercentage = (zoom: number): number => {
return Math.round((zoom / MULTIPLIER) * 100 + RECOMMENDED);
return (zoom / MULTIPLIER) * 100 + RECOMMENDED;
};

0 comments on commit c86e7fd

Please sign in to comment.