Improved window dragging for
Frameless windows can be dragged using the -webkit-app-region css property, but this disables all regular dom events and user interactions with the affected element, which makes it hard to emulate a native-like title bar in the application, as it's not possible to capture double clicks for maximizing the window.
This module uses osx-mouse or win-mouse modules for tracking the mouse position on the entire screen, and thereby enabling consistent window dragging, while the affected element is still able to receive dom events.
npm install electron-drag
Require the module in an
Electron web page.
var drag = ;// Pass a query selector or a dom element to the function.// Dragging the element will drag the whole window.var clear = ;// Call the returned function to make the element undraggable again.;
The module only works on OS X and Windows, but doesn't fail when installed on a non-supported platform.
// Fallback to using -webkit-app-region property.if!dragsupporteddocumentstyle'-webkit-app-region' = 'drag';
The module needs to be built with the correct
Electron headers. See the guide for using native Node modules with Electron for more information.