Skip to content

Commit

Permalink
webview: Use an exponential scale for zooming.
Browse files Browse the repository at this point in the history
This matches the native Electron behavior.

Fixes part of #1360 by removing the separate zoomFactor state
variable.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk committed Mar 21, 2024
1 parent af7272a commit bc75eba
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/renderer/js/components/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export default class WebView {

badgeCount = 0;
loading = true;
private zoomFactor = 1;
private customCss: string | false | null;
private readonly $webviewsContainer: DOMTokenList;
private readonly $unsupported: HTMLElement;
Expand Down Expand Up @@ -161,18 +160,15 @@ export default class WebView {
}

zoomIn(): void {
this.zoomFactor += 0.1;
this.getWebContents().setZoomFactor(this.zoomFactor);
this.getWebContents().zoomLevel += 0.5;
}

zoomOut(): void {
this.zoomFactor -= 0.1;
this.getWebContents().setZoomFactor(this.zoomFactor);
this.getWebContents().zoomLevel -= 0.5;
}

zoomActualSize(): void {
this.zoomFactor = 1;
this.getWebContents().setZoomFactor(this.zoomFactor);
this.getWebContents().zoomLevel = 0;
}

logOut(): void {
Expand Down

0 comments on commit bc75eba

Please sign in to comment.