2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 02:28:55 +00:00

Fix #474: Remember custom zoom level (PR #582)

... by using setZoomFactor instead of sending change-zoom event.
This commit is contained in:
David Kramer 2018-04-22 12:54:29 -07:00 committed by Ronan Jouchet
parent 574205ab0d
commit 454ab1e7bd
2 changed files with 9 additions and 15 deletions

View File

@ -102,20 +102,18 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options)); fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options));
} }
let currentZoom = options.zoom; const adjustWindowZoom = (window, adjustment) => {
window.webContents.getZoomFactor((zoomFactor) => {
const onZoomIn = () => { window.webContents.setZoomFactor(zoomFactor + adjustment);
currentZoom += ZOOM_INTERVAL; });
mainWindow.webContents.send('change-zoom', currentZoom);
}; };
const onZoomOut = () => { const onZoomIn = () => adjustWindowZoom(mainWindow, ZOOM_INTERVAL);
currentZoom -= ZOOM_INTERVAL;
mainWindow.webContents.send('change-zoom', currentZoom); const onZoomOut = () => adjustWindowZoom(mainWindow, -ZOOM_INTERVAL);
};
const onZoomReset = () => { const onZoomReset = () => {
mainWindow.webContents.send('change-zoom', options.zoom); mainWindow.webContents.setZoomFactor(options.zoom);
}; };
const clearAppData = () => { const clearAppData = () => {

View File

@ -1,7 +1,7 @@
/** /**
Preload file that will be executed in the renderer process Preload file that will be executed in the renderer process
*/ */
import { ipcRenderer, webFrame } from 'electron'; import { ipcRenderer } from 'electron';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
@ -78,7 +78,3 @@ ipcRenderer.on('debug', (event, message) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
log.info('debug:', message); log.info('debug:', message);
}); });
ipcRenderer.on('change-zoom', (event, message) => {
webFrame.setZoomFactor(message);
});