From f6b8e73eb1d2f3a191312c8b8af629cd6e4d45ac Mon Sep 17 00:00:00 2001 From: Cosmo Myzrail Gorynych aka CoMiGo Date: Tue, 24 Sep 2024 20:03:48 +1200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Document=20the=20new=20argument?= =?UTF-8?q?=20in=20window.setDraggableRegion=20(#342)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :pencil: Document the new argument in window.setDraggableRegion. A follow-up to https://github.com/neutralinojs/neutralino.js/pull/120 * :pencil: Add an example to window.setDraggableRegion that uses options --- docs/api/window.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/api/window.md b/docs/api/window.md index 61981481..974064ec 100644 --- a/docs/api/window.md +++ b/docs/api/window.md @@ -157,15 +157,26 @@ const icon = '/resources/icons/appIcon.png'; await Neutralino.window.setIcon(icon); ``` -## window.setDraggableRegion(domId) +## window.setDraggableRegion(domId, options) Converts a given DOM element to a draggable region. The user will be able to drag the native window by dragging the given DOM element. This feature is suitable to make custom window bars along with the [borderless mode](../configuration/neutralino.config.json#modeswindowborderless-boolean). ### Parameters - `domId` String | HTMLElement: A DOM element identifier. +- `options` DraggableRegionOptions (optional): Customize the behavior of the draggable region. + +### DraggableRegionOptions + +- `alwaysCapture` Boolean (optional): If set to `true`, the region will always capture the pointer, ensuring that dragging is not interrupted when moving the pointer quickly. Note that it prevents child elements from receiving any pointer events. Defaults to `false`. +- `dragMinDistance` Number (optional): The minimum distance between cursor's starting and current position after which dragging is started. This helps prevent accidental dragging while interacting with child elements. Defaults to `10` and is measured in CSS pixels. ```js await Neutralino.window.setDraggableRegion('myCustomTitleBar'); + +await Neutralino.window.setDraggableRegion('myCustomTitleBar', { + alwaysCapture: true, + dragMinDistance: 15 +}); ``` ## window.unsetDraggableRegion(domId)