-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from klauscfhq/zoom-options
Zooming options support
- Loading branch information
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
const electron = require('electron'); | ||
const config = require('./config'); | ||
|
||
const ipc = electron.ipcRenderer; | ||
const webFrame = electron.webFrame; | ||
|
||
ipc.on('zoom-in', () => { | ||
// Get zoom factor and increase it | ||
const currentZoomFactor = webFrame.getZoomFactor(); | ||
const zoomFactor = currentZoomFactor + 0.05; | ||
// Upper bound check | ||
if (zoomFactor < 1.3) { | ||
webFrame.setZoomFactor(zoomFactor); | ||
config.set('zoomFactor', zoomFactor); | ||
} | ||
}); | ||
|
||
ipc.on('zoom-out', () => { | ||
// Get zoom factor and decrease it | ||
const currentZoomFactor = webFrame.getZoomFactor(); | ||
const zoomFactor = currentZoomFactor - 0.05; | ||
// Lower bound check | ||
if (zoomFactor > 0.7) { | ||
webFrame.setZoomFactor(zoomFactor); | ||
config.set('zoomFactor', zoomFactor); | ||
} | ||
}); | ||
|
||
ipc.on('zoom-reset', () => { | ||
// Reset zoom factor | ||
webFrame.setZoomFactor(1.0); | ||
config.set('zoomFactor', 1.0); | ||
}); | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
// Preserve zoom factor | ||
const zoomFactor = config.get('zoomFactor'); | ||
webFrame.setZoomFactor(zoomFactor); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters