• Stars
    star
    320
  • Rank 131,126 (Top 3 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Window dragging for electron applications

electron-drag

Improved window dragging for Electron applications.

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.

A workaround is to use a pure javascript solution, but dragging only works well when moving the mouse in less than normal speed, else the mouse pointer will move outside the window area and no events will be received by the dom.

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.

Build

The module needs to be built with the correct Electron headers. See the guide for using native Node modules with Electron for more information.

Versions of this library above version 2.0.0 require Electron which support Node.js version 9 and above.

Usage

npm install electron-drag

Require the module in an Electron web page.

var drag = require('electron-drag')

// Pass a query selector or a dom element to the function.
// Dragging the element will drag the whole window.
var clear = drag('#element')

// Call the returned function to make the element undraggable again.
clear()

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 (!drag.supported) {
	document.querySelector('#element').style['-webkit-app-region'] = 'drag'
}

More Repositories

1

titlebar

Emulate OS X window title bar
JavaScript
484
star
2

dns

A DNS library written in C#
C#
395
star
3

jquery-observe

Observe DOM mutations with jQuery
JavaScript
135
star
4

osx-mouse

Mouse tracking for OS X
C++
73
star
5

win-mouse

Mouse tracking for Windows
C++
52
star
6

repaint

HTML layout engine
JavaScript
48
star
7

css-shorthand-expand

Expand CSS shorthand properties
JavaScript
46
star
8

text-width

Measure the text width in browsers
JavaScript
20
star
9

audio-stream

Stream raw audio data from a MediaStream
JavaScript
19
star
10

browser-beep

Beeping sound in browser using Web Audio API
JavaScript
16
star
11

cordova-plugin-android-wifi-manager

Cordova plugin for accessing Android WifiManager
Java
15
star
12

vue-long-press-directive

Long press directive plugin for Vue.js
JavaScript
10
star
13

syntactical

Browserify transform that emits a descriptive syntax error on invalid javascript
JavaScript
9
star
14

text-height

Measure the text height in browsers
JavaScript
9
star
15

service-names-port-numbers

IANA assigned port numbers
JavaScript
9
star
16

redditor

Minimal reddit API wrapper
JavaScript
7
star
17

the-hunt

2D multiplayer game for the browser
JavaScript
5
star
18

extended-inquiry-response

Bluetooth EIR encoder and decoder
JavaScript
5
star
19

remote-procedure-call-stream

Binary RPC protocol stream
JavaScript
4
star
20

reddit-thread-stream

Writable stream for updating reddit self threads
JavaScript
4
star
21

http.m

A HTTP server library written in Objective-C
Objective-C
4
star
22

render-html

Web component for server-side rendering HTML as images
JavaScript
4
star
23

osx-mouse-stream

Streaming mouse events for OS X
JavaScript
4
star
24

cyclic-array

Simple cyclic array (buffer) implementation
JavaScript
4
star
25

audio-activity

Detect audio activity of a MediaStream
JavaScript
3
star
26

noise-protocol-stream

Node stream wrapper for Noise Protocol C implementation compiled to WebAssembly
JavaScript
3
star
27

iServe

iOS application for serving device assets over HTTP
Objective-C
2
star
28

ruby-mud

A simple package manager for client-side Javascript
Ruby
2
star
29

ejs-stream

Through stream for rendering objects with ejs templates
JavaScript
2
star
30

elite

Tournament web application
JavaScript
2
star
31

service-port

Map a service name to a port number
JavaScript
2
star
32

taco-deploy-extract

Extract tarballs into taco deployment directories
JavaScript
2
star
33

npm-install-cache

Install node_modules from cache
Shell
2
star
34

indexeddown

Leveldown API implementation on top of IndexedDB
JavaScript
2
star
35

ruby-tracker

A small BitTorrent tracker written in Ruby
Ruby
1
star
36

jett

A Java API wrapper for Ge.tt
Java
1
star
37

root.redirects

Redirection handling for root
JavaScript
1
star
38

repaint-chrome

Simple interface for repaint
JavaScript
1
star
39

bitless

A small BitTorrent client written in Python
Python
1
star
40

jquery-tag

A jQuery tagging plugin for input fields
JavaScript
1
star
41

level-tail-stream

Tailable stream from levelup compliant store
JavaScript
1
star
42

get-stats

Basic RTCPeerConnection statistics
JavaScript
1
star
43

bitless.js

A small BitTorrent client written in Javascript
JavaScript
1
star
44

pcm-stream

A transform stream for converting audio encoded as 32-bit floats to 16-bit intergers
JavaScript
1
star
45

dribler

Soccer event stream
JavaScript
1
star
46

ebml-decoder

EBML decoder stream
JavaScript
1
star
47

cordova-plugin-android-imei

Cordova plugin for retrieving IMEI of the device
Java
1
star