I am interested in creating man machine interfaces with Electron. Trying to do a demo with the Star trek life signs monitor. Found this code that is easily modified to move up and down : http://jsfiddle.net/anex6vmq/
Here is my HTML and Javascript:
<html>
<head>
<style>
div.a {
width: 50px;
height: 50px;
background-color: red;
position: fixed;
}
</style>
</head>
<body background="startrekbg.png">
<div class='a'></div>
<script type="text/javascript">
$(document).ready(function () {
animateDiv();
});
function makeNewPosition() {
// Get viewport dimensions (remove the dimension of the div)
var h = $(window).height() - 500;
var w = $(window).width() - 500;
var nh = Math.floor(Math.random() * h);
var nw = Math.floor(Math.random() * w);
//var nw = 777;
return [nh, nw];
}
function animateDiv() {
var newq = makeNewPosition();
$('.a').animate({ top: newq[0], left: newq[1] }, function () {
animateDiv();
});
};
</script>
</body>
</html>
main.js code :
const {app, BrowserWindow} = require('electron')
let mainWindow
app.on('ready', () => {
mainWindow = new BrowserWindow({
height: 670,
width: 995,
frame: false
})
mainWindow.loadURL('file://' + __dirname + '/animation.html')
})
And my package.json :
`{
"name": "Sick Bay Scanner by H.A. Hobson",
"version": "1.0.1",
"main": "main.js"
}`
I work mostly with C, PHP and Python. Have not done much JavaScript, but find Node and Electron very exciting things to learn. Thanks for your attention.