maccman/macgap — pull request #91 by jeff-h (2014-03-02 02:49:20+00:00)
Title: window.getX() and getY() methods

Simple addition to allow javascript to read the X,Y coordinates of the window. Amongst other things this is useful to allow javascript to move the window around when an element in the DOM is dragged. I tested this using the following code:

```
var dragging = false;
document.onmousemove = function() {
if (!dragging) return;
macgap.window.move({
x: macgap.window.getX() + event.clientX - xstart,
y: macgap.window.getY() +ystart - event.clientY,
});
}

document.onmousedown = function(){
dragging = true;
xstart = event.clientX;
ystart = event.clientY;
}

document.onmouseup = function(){
dragging = false;
}
```

Note, this technique has an unavoidable flaw; you won't be able to drag the app onto another space like you should.