2022-04-21 01:16:36 +00:00
|
|
|
// https://stackoverflow.com/questions/67971689/positioning-the-borderless-window-in-neutralino-js
|
|
|
|
// had to use this since the in-built function breaks the close and minimize buttons
|
2022-04-25 06:38:06 +00:00
|
|
|
let dragging = false, ratio = 1, posX, posY;
|
2022-04-21 01:16:36 +00:00
|
|
|
let draggable;
|
|
|
|
|
2022-04-25 06:38:06 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
2022-04-21 01:16:36 +00:00
|
|
|
draggable = document.getElementById('controlBar');
|
|
|
|
|
2022-04-21 08:20:41 +00:00
|
|
|
// Listen to hovers
|
2022-04-21 01:16:36 +00:00
|
|
|
draggable.onmousedown = function (e) {
|
2022-04-25 06:38:06 +00:00
|
|
|
ratio = window.devicePixelRatio
|
|
|
|
|
|
|
|
posX = e.pageX * ratio, posY = e.pageY * ratio;
|
2022-04-21 01:16:36 +00:00
|
|
|
dragging = true;
|
|
|
|
}
|
|
|
|
|
2022-04-25 06:38:06 +00:00
|
|
|
// Patch for monitors with scaling enabled, allows them to detach from the titlebar anywhere
|
|
|
|
window.onmouseup = function (e) {
|
2022-04-21 01:16:36 +00:00
|
|
|
dragging = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.onmousemove = function (e) {
|
2022-04-25 06:38:06 +00:00
|
|
|
if (dragging) Neutralino.window.move(e.screenX * ratio - posX, e.screenY * ratio - posY);
|
2022-04-21 01:16:36 +00:00
|
|
|
}
|
|
|
|
})
|