With IDE electron code


#1

I am a beginner in HTML and CSS and managed to do some cool things with the electron but I am having doubts in a code. I need to create a code that depending on a condition the generated DESKTOP window has different sizes … a pseudo-code:

If (condition 1) {
Window with maximized dimension
}

If (condition 2) {
Window with fullscreen dimension
}

My question is just how do I access the properties (in the API called options) of the BrowserWindow function that was already instantiated …

Thank you for your help…


#2

I’m surprised no one responded to you… It’s a bit late but it’s really simple!

var size = BrowserWindow.getSize()
console.log(`Width: ${size[0]}, Height: ${size[1]}`

To set the size properties…

If(someCondition){
    BrowserWindow.setSize(500,500)
} else {
    BrowserWindow.setSize(300,500)
}

See docs


#3

Assuming this is only for adjusting layouts based on the window dimensions, you could also just use CSS media queries to adjust the content based on the window dimensions.