kapetan / electron-drag Goto Github PK
View Code? Open in Web Editor NEWWindow dragging for electron applications
Window dragging for electron applications
It automatically increasing window size when element dragged on windows platform.
after " npm install electron-drag " ,then,I use
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();
but get the wrong msg " Uncaught TypeError: clear is not a function "
would friends know why
platform: windows 10
when click element to drag, the element will goto error position
Hello,
Since a week I tried everything to fix compilation error : including reinstalling node-gyp, all the vs libraries, cleaning caches... There is no way I can build my app with your module.
When I install the module, I do a node-gyp configure && node-gyp rebuild
and it's give me theses errors:
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. bufferutil.cc win_delay_load_hook.cc c1xx : fatal error C1083: Cannot open source file: '..\src\bufferutil.cc': No such file or directory [D:\Code\XXX\node_modules\electron-drag\build\bufferutil.vcxproj] validation.cc win_delay_load_hook.cc c1xx : fatal error C1083: Cannot open source file: '..\src\validation.cc': No such file or directory [D:\Code\XXX\node_modules\electron-drag\build\validation.vcxproj] gyp ERR! build error
I have seen all the topics talking about theses errors and I didn't find a way to fix them. If there is no hop for me, it's there a way to make frameless window dragable properly ?
I use npm install electron-drag
to install electron-drag in my electron app.
But it report some errors. Here is the install error reports.
It might be more easily to read in a file
report.txt
My system is Windows 10 x64
Also I think I have installed windows-build-tools
and node-gyp
correctly.
C:\Users\intmain>node-gyp list
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
14.15.4
gyp info ok
After installing with npm install electron-drag on macOS 10.13.4 I get below respons. Otherwise installs fine.
> ../source/mouse.cc:179:18: warning: 'Call' is deprecated [-Wdeprecated-declarations]
> event_callback->Call(3, argv);
> ^
> ../../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
> NAN_DEPRECATED inline v8::Local<v8::Value>
> ^
> ../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
> # define NAN_DEPRECATED __attribute__((deprecated))
On electron version striclty upper than 11.2.3 and Mac OS BigSur
The lib doesn't work anymore
Here what I have got :
When I reload electron it crash my devtools every second time
This is the error I got
This is my code
import React from 'react';
import drag from 'src/electron/services/dragWindow';
/**
* Allow the browser window to be drag by a DOM element
*/
export default (querySelector: string) => {
React.useEffect(() => {
const clear = drag?.(querySelector);
return () => {
clear();
};
}, [querySelector]);
};
import drag from 'electron-drag';
export default (querySelector: string) => {
return drag(querySelector);
};
Maybe it can help, here I found the commit in electron where it is about drag window electron/electron@3bcdc27
There's a new option in Electron 2.0 called 'affinity' which allows multiple windows to be run in the same render process. Using electron-drag with affinity works for the first window in the group, but the win-mouse tryRequire throws an error on all subsequent windows:
C:\Users\Chaz\Documents\pokeit-hud-x64\node_modules\bindings\bindings.js:88 Uncaught Error: Module did not self-register.
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:671:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at Module.require (module.js:586:17)
at require (internal/module.js:11:18)
at bindings (C:\Users\Chaz\Documents\pokeit-hud-x64\node_modules\bindings\bindings.js:81:44)
at Object.<anonymous> (C:\Users\Chaz\Documents\pokeit-hud-x64\node_modules\win-mouse\index.js:3:13)
electron/js2c/renderer_init.js:2341 Error: The module '/Users/elliotyan/Documents/me/electron-with-sqlite3/node_modules/osx-mouse/build/Release/addon.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 76. Please try re-compiling or re-installing
looks like linux-mouse is missing…
Electron: Loading non-context-aware native module in renderer: '\?\D:\JSE Media Player\JSE-Media-Player\node_modules\win-mouse\build\Release\addon.node'. This is deprecated, see electron/electron#18397.
Any plans to update this to fix this issue?
Uncaught Error: The module '\?\C:\Code\pc\node_modules\win-mouse\build\Release\addon.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 80. Please try re-compiling or re-installing
the module (for instance, using npm rebuild
or npm install
).
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1034:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at bindings (C:\Code\pc\node_modules\win-mouse\node_modules\bindings\bindings.js:112:48)
at Object. (C:\Code\pc\node_modules\win-mouse\index.js:3:13)
But id dosn't find the version "80" in https://nodejs.org/en/download/releases/
What should I do with this error?
When I do npm install
on windows, I get an error telling me it can't build osx-mouse. Is there a way to specify that I only want it to try to build win-mouse?
I did some googling and found this on SO (http://stackoverflow.com/questions/15176082/npm-package-json-os-specific-dependency), but none of the solutions seem that great. Wondering if there is anything else.
I don't mind the errors that much when working locally, but my CI server doesn't like them at all and fails the build.
C:\MyApp\node_modules\electron-drag\node_modules\osx-mouse>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
addon.cc
mouse.cc
c:\MyApp\node_modules\electron-drag\node_modules\osx-mouse\source\mouse.h(4): fatal error C1083: Cannot open include file: 'CoreGraphics/CoreGraphics.h': No such file or directory (..\source\mouse.cc) [C:\MyApp\node_modules\e lectron-drag\node_modules\osx-mouse\build\addon.vcxproj]
c:\MyApp\node_modules\electron-drag\node_modules\osx-mouse\source\mouse.h(4): fatal error C1083: Cannot open include file: 'CoreGraphics/CoreGraphics.h': No such file or directory (..\source\addon.cc) [C:\MyApp\node_modules\e lectron-drag\node_modules\osx-mouse\build\addon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\MyApp\node_modules\electron-drag\node_modules\osx-mouse
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
I went through the code since it's neat and simple. It returns as noop
. It's really strange actually. I don't understand how Electron guys wanted us to make draggable custom title-bars while events cannot pass through. With code age I'm suspecting this approach needs an update.
When I had troubles in dragging window, I saw this project and I install it.
But when I require with require('electron-drag')
in the .vue, the console drop these error:
Uncaught Error: Could not locate the bindings file. Tried:
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\build\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\build\Debug\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\build\Release\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\out\Debug\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\Debug\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\out\Release\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\Release\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\build\default\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\compiled\8.9.3\win32\x64\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\addon-build\release\install-root\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\addon-build\debug\install-root\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\addon-build\default\install-root\addon.node
→ A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\lib\binding\node-v57-win32-x64\addon.node
at bindings (A:\desktop\project\orderer\orderer\node_modules\[email protected]@bindings\bindings.js:126)
at Object.<anonymous> (A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\index.js:3)
at Object.<anonymous> (A:\desktop\project\orderer\orderer\node_modules\[email protected]@win-mouse\index.js:41)
at Module._compile (module.js:642)
at Object.Module._extensions..js (module.js:653)
at Module.load (module.js:561)
at tryModuleLoad (module.js:504)
at Function.Module._load (module.js:496)
at Module.require (module.js:586)
at require (internal/module.js:11)
And I tried to rebuild with npm rebuild
and it dropped these error:
> [email protected] install A:\desktop\project\orderer\orderer\node_modules\[email protected]@osx-mouse
> node-gyp rebuild
A:\desktop\project\orderer\orderer\node_modules\[email protected]@osx-mouse>if not defined npm_config_node_gyp (node "D:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\HP\AppData\Local\Programs\Python\Python36\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd A:\desktop\project\orderer\orderer\node_modules\[email protected]@osx-mouse
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache\_logs\2020-01-21T08_43_00_771Z-debug.log
I don't know how to fix it.
My platform is Windows 10, I saw an issue with osx-mouse, and its solution is to add "os": "darwin],
in pakage.json for osx-mouse, but that already existed in that pakage.json.
Someone could help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.