mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-30 11:10:04 +00:00
feat: add mousewheel zoom for electron
This commit is contained in:
parent
eb01a6bea3
commit
55a79cd69f
1 changed files with 16 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ export class AppComponent implements OnInit {
|
|||
if (IS_ELECTRON) {
|
||||
this._electronService.ipcRenderer.send(IPC_APP_READY);
|
||||
this._initElectronErrorHandler();
|
||||
this._initMousewheelZoomForElectron();
|
||||
|
||||
this._electronService.ipcRenderer.on(IPC_TRANSFER_SETTINGS_REQUESTED, () => {
|
||||
this._electronService.ipcRenderer.send(IPC_TRANSFER_SETTINGS_TO_ELECTRON, this._configService.cfg);
|
||||
|
|
@ -152,4 +153,19 @@ export class AppComponent implements OnInit {
|
|||
console.error(data);
|
||||
});
|
||||
}
|
||||
|
||||
private _initMousewheelZoomForElectron() {
|
||||
const ZOOM_DELTA = 0.05;
|
||||
const webFrame = this._electronService.webFrame;
|
||||
document.addEventListener('mousewheel', (event: MouseWheelEvent) => {
|
||||
if (event && event.ctrlKey) {
|
||||
const zoomFactor = webFrame.getZoomFactor();
|
||||
if (event.deltaY > 0) {
|
||||
webFrame.setZoomFactor(zoomFactor + ZOOM_DELTA);
|
||||
} else if (event.deltaY < 0) {
|
||||
webFrame.setZoomFactor(zoomFactor - ZOOM_DELTA);
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue