Skip to content

Commit bc75eba

Browse files
committed
webview: Use an exponential scale for zooming.
This matches the native Electron behavior. Fixes part of #1360 by removing the separate zoomFactor state variable. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent af7272a commit bc75eba

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

app/renderer/js/components/webview.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export default class WebView {
105105

106106
badgeCount = 0;
107107
loading = true;
108-
private zoomFactor = 1;
109108
private customCss: string | false | null;
110109
private readonly $webviewsContainer: DOMTokenList;
111110
private readonly $unsupported: HTMLElement;
@@ -161,18 +160,15 @@ export default class WebView {
161160
}
162161

163162
zoomIn(): void {
164-
this.zoomFactor += 0.1;
165-
this.getWebContents().setZoomFactor(this.zoomFactor);
163+
this.getWebContents().zoomLevel += 0.5;
166164
}
167165

168166
zoomOut(): void {
169-
this.zoomFactor -= 0.1;
170-
this.getWebContents().setZoomFactor(this.zoomFactor);
167+
this.getWebContents().zoomLevel -= 0.5;
171168
}
172169

173170
zoomActualSize(): void {
174-
this.zoomFactor = 1;
175-
this.getWebContents().setZoomFactor(this.zoomFactor);
171+
this.getWebContents().zoomLevel = 0;
176172
}
177173

178174
logOut(): void {

0 commit comments

Comments
 (0)