I have an element in the HTML of the electron window and I don't know how wide the element will be. How can I set the minimum width of the electron BrowserWindow
which was created in main.js
to be equal to the width of said HTML element?
I tried using element.offsetWidth
in the index.html
file to get the element's width and then using the below code in the same file to set the window's minimum size, but the size ended up being off somehow. I don't know why. It seems from some console output that it should be working.
var remote = require('electron').remote;
var win = remote.getCurrentWindow();
win.setMinimumSize(elementWidth, 400);
My guess is that my screen's pixel are not the same size as the CSS pixels, but I'm not really sure. Is there just a better way to do this altogether or am I missing something?
via Aaron Beaudoin
No comments:
Post a Comment