-
Notifications
You must be signed in to change notification settings - Fork 8
Add custom drag handler to reimplement custom menu bar #2
Comments
This is implemented for OSX - need to reimplement for other platforms |
@jacobwgillespie hey i'm interested in helping you out with development if you're open to that. is there something small i can help with? |
Hey @benortiz! Feel free to contribute anywhere, I'm totally open to contributions! I have a pseudo list of todo items on this issue comment over on radiant-player-mac: radiant-player/radiant-player-mac#409 (comment). Essentially a settings system, theming system, and LastFM scrobbling are the remaining areas that need to be implemented. |
First off, apologies for the jQuery 😆 And on that note, have a code sample showing how to do cross platform window dragging with Electron API's. import { remote } from 'electron';
let wX;
let wY;
let dragging = false;
$('.draggable').mousedown(function (e) {
dragging = true;
wX = e.pageX;
wY = e.pageY;
});
$(window).mousemove(function (e) {
e.stopPropagation();
e.preventDefault();
if (dragging) {
var xLoc = e.screenX - wX;
var yLoc = e.screenY - wY;
try {
remote.BrowserWindow.getFocusedWindow().setPosition(xLoc, yLoc);
} catch (err) {
console.log(err);
}
}
});
$(window).mouseup(function () {
dragging = false;
}); |
Sweet thanks, I should probably test that solution. From what I read, implementing Electron drag in pure-JS could have potential performance implications, i.e. not register drags fast enough and run the risk of the mouse moving outside the player window and thus "losing" the window in the process, hence why I went with a native solution that grabs |
@jacobwgillespie I've tested this on OS X and Windows and the beauty of it is the use of I've deliberately tried to "lose" the window by dragging it quickly and I just can't seem to lose it 😆 |
Check out https://github.com/kapetan/electron-drag - it implements drag in native code. We will need to reimplement though as it uses dynamic imports, which are broken by design in ES6.
The text was updated successfully, but these errors were encountered: