Created
April 21, 2016 21:06
-
-
Save bayleedev/1836954796536ffe684e151b39b38517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Electron Boilerplate</title> | |
<script src="helpers/context_menu.js"></script> | |
<script src="helpers/external_links.js"></script> | |
<style> | |
body { margin: 0 } | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
</div> | |
<script> | |
const { remote } = require('electron') | |
const electronScreen = require('electron').screen | |
const maxHeight = 500 | |
// Have the content grow | |
var container = document.getElementById('container') | |
setInterval(function() { | |
var newNode = document.createElement('div'); | |
newNode.innerHTML = new Date() | |
container.appendChild(newNode); | |
// updateHeight() // push change events, if possible | |
}, 100); | |
// pull change events | |
setInterval(function() { | |
updateHeight() | |
}, 100); | |
// Update the height of the browser window | |
function updateHeight() { | |
var currentWindow = remote.getCurrentWindow() | |
const { height, width, y } = currentWindow.getBounds() | |
var screenHeight = electronScreen.getPrimaryDisplay().workAreaSize.height | |
var newHeight = Math.min( | |
maxHeight, | |
container.offsetHeight, | |
screenHeight - y | |
) | |
console.log({newHeight, height}) | |
if (newHeight !== height) { | |
currentWindow.setSize(width, newHeight) | |
} | |
} | |
</script> | |
</body> | |
</html> |
Author
bayleedev
commented
Apr 26, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment