drag windows in desktop, not using chrome
How can I implement the drag and move window capabilities while not using the native Chrome?
I have a header within a window that has a close button. It will close the app just fine.
So I want to add to the header a "drag and move" function in order to reposition the window.
Thanks in advance!
JDH
1 Answer
-
Not sure if this works, but I found it.
"First, get your "handler" to trigger Window_Drag_Handler() on onmousedown, onmouseup and onmouseout.
Then add this script:
"var CursorPosition = 0; function Window_Drag(event) { window.moveTo(event.screenX-CursorPosition[0], event.screenY-CursorPosition[1]); } function Window_Drag_Handler(event) { if (!event) var event = window.event; if (event.type == "mousedown") { CursorPosition = [event.clientX, event.clientY]; window.addEventListener("mousemove", Window_Drag); } else if (event.type == "mouseup" || event.type == "mouseout") { window.removeEventListener("mousemove", Window_Drag); } }
"There's some issues with it tho, the window is constrained withing the screen sides and you can't drag it outside the screen limits. One other issue is the "onmouseout" not behaving as I wish it was but it's still better than not having it included."