mirror of
https://codeberg.org/armin/noizapp.git
synced 2026-09-01 05:50:52 +02:00
fix resize (both keyboard and mouse should work)
This commit is contained in:
parent
704e42550c
commit
154a98a754
2 changed files with 59 additions and 2 deletions
31
main.js
31
main.js
|
|
@ -1,11 +1,38 @@
|
|||
const { app, BrowserWindow, Menu } = require('electron');
|
||||
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
|
||||
|
||||
let zoomLevel = 0;
|
||||
const MIN_ZOOM = -5;
|
||||
const MAX_ZOOM = 5;
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
preload: __dirname + '/preload.js',
|
||||
},
|
||||
});
|
||||
win.loadURL('https://bsd.pm/noiz/');
|
||||
|
||||
ipcMain.on('zoom-in', () => {
|
||||
if (zoomLevel < MAX_ZOOM) {
|
||||
zoomLevel += 1;
|
||||
win.webContents.setZoomLevel(zoomLevel);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('zoom-out', () => {
|
||||
if (zoomLevel > MIN_ZOOM) {
|
||||
zoomLevel -= 1;
|
||||
win.webContents.setZoomLevel(zoomLevel);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('zoom-reset', () => {
|
||||
zoomLevel = 0;
|
||||
win.webContents.setZoomLevel(0);
|
||||
});
|
||||
}
|
||||
|
||||
Menu.setApplicationMenu(null);
|
||||
app.whenReady().then(createWindow);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue