Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a minimum width limit for the window? #8234

Open
ssnangua opened this issue Nov 12, 2024 · 0 comments
Open

Is there a minimum width limit for the window? #8234

ssnangua opened this issue Nov 12, 2024 · 0 comments
Labels

Comments

@ssnangua
Copy link

ssnangua commented Nov 12, 2024

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants