Open
Description
Issue
I set the window width to 50px, but the result is larger than 50px.
Is there a minimum width limit for the window?
Code snippet
package.json
{
"name": "floating-icon-test",
"version": "0.0.1",
"main": "index.html",
"window": {
"id": "floating-icon",
"width": 50,
"height": 50,
"frame": false,
"transparent": true,
"resizable": true,
"always_on_top": true,
"show_in_taskbar": true
}
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Floating Icon</title>
<style>
html,
body {
padding: 0;
margin: 0;
background-color: #fff;
}
.icon {
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
}
</style>
</head>
<body>
<div class="icon"></div>
<script>
const icon = document.querySelector(".icon");
const win = nw.Window.get();
let pos = { x: 0, y: 0 };
function onMouseDown(e) {
pos = { x: e.pageX, y: e.pageY };
window.addEventListener("mousemove", onMouseMove);
window.addEventListener("mouseup", onMouseUp);
}
function onMouseMove(e) {
win.moveTo(e.screenX - pos.x, e.screenY - pos.y);
}
function onMouseUp(e) {
window.removeEventListener("mousemove", onMouseMove);
window.removeEventListener("mouseup", onMouseUp);
}
icon.addEventListener("mousedown", onMouseDown);
</script>
</body>
</html>