admin管理员组文章数量:1390564
How can I properly add border to a frameless electron browser window? My frameless window height is according to the content in the page which makes it difficult to add border around it.
This is how i'm doing it now:
1) I'm adding the border to html:
html{
border-style: solid;
border-color: slategray;
border-width: 5px;
}
2) calculating the height of the window from the renderer side js:
let pageHeight = ( $('body').outerHeight(true));
$('html').height(Math.ceil(pageHeight));
let margin = 9;
let electronWindowHt = Math.ceil(pageHeight)+margin;
ipcRenderer.send('dom-ready-mand',electronWindowHt);
3) setting the size of the window from the main js:
ipc.on('dom-ready-mand', (event, height) => {
clipboardWindow.setSize(config.WIDTH, height, false);
clipboardWindow.setPosition(clipwin_x, clipwin_y, false);
// other code
.
.
.
})
The issue is it is not pixel perfect. Sometimes it works fine but sometimes when html body content increases or decreases I get a bit smaller height electron window than the content. which hides the bottom border and I need to scroll up to see that border. If I increase the height a bit then next time I get some white space left below the bottom border. Width is not an issue as it is always fixed.
As you can see in the below image, bottom border is hidden a bit because of smaller electron window size as pared to the content of HTML body.
So how can I make it pixel perfect?
How can I properly add border to a frameless electron browser window? My frameless window height is according to the content in the page which makes it difficult to add border around it.
This is how i'm doing it now:
1) I'm adding the border to html:
html{
border-style: solid;
border-color: slategray;
border-width: 5px;
}
2) calculating the height of the window from the renderer side js:
let pageHeight = ( $('body').outerHeight(true));
$('html').height(Math.ceil(pageHeight));
let margin = 9;
let electronWindowHt = Math.ceil(pageHeight)+margin;
ipcRenderer.send('dom-ready-mand',electronWindowHt);
3) setting the size of the window from the main js:
ipc.on('dom-ready-mand', (event, height) => {
clipboardWindow.setSize(config.WIDTH, height, false);
clipboardWindow.setPosition(clipwin_x, clipwin_y, false);
// other code
.
.
.
})
The issue is it is not pixel perfect. Sometimes it works fine but sometimes when html body content increases or decreases I get a bit smaller height electron window than the content. which hides the bottom border and I need to scroll up to see that border. If I increase the height a bit then next time I get some white space left below the bottom border. Width is not an issue as it is always fixed.
As you can see in the below image, bottom border is hidden a bit because of smaller electron window size as pared to the content of HTML body.
So how can I make it pixel perfect?
Share Improve this question edited Nov 24, 2017 at 9:48 GorvGoyl asked Nov 9, 2017 at 7:20 GorvGoylGorvGoyl 49.9k37 gold badges261 silver badges264 bronze badges 04 Answers
Reset to default 5My stoned cousin put clipboardWindow.setSize(config.WIDTH, Math.ceil(height), false);
at the last line of ipc.on('dom-ready-mand')
event.
Strangely enough, it fixed the issue with the incorrect height. Now it's pixel perfect
本文标签: javascriptAdd border to frameless windowElectronStack Overflow
版权声明:本文标题:javascript - Add border to frameless window - Electron - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744673692a2618982.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论