Fullstack Devs
Fullstack Devs

Reputation: 41

electron win.unmaximize(); not working

i am using electron to make a desktop app, I made my own minimize maximize and close buttons, all of them are working fine, but when you click on maximize and it already is maximized it is not being unmaximized. here is my code:

const $ = require('jquery');
const {remote} = require('electron');
var win = remote.getCurrentWindow();

$('#minimize').click(function(){
  win.minimize();
});

$('#close').click(function(){
  win.close();
});

$('#maximize').click(function() {
  if(win.isMaximized()){
      win.unmaximize();
  }else{
      win.maximize();
  }
});

Any help appreciated.

Upvotes: 2

Views: 2331

Answers (1)

Kailash P
Kailash P

Reputation: 438

Instead of unmaximize use restore as below, it will work.

$('#maximize').click(function() {
  if(win.isMaximized()){
      win.restore();
  }else{
      win.maximize();
  }
});

Upvotes: 5

Related Questions