Skip to content

Instantly share code, notes, and snippets.

@b00gizm
Created August 27, 2009 21:44
Show Gist options
  • Save b00gizm/176584 to your computer and use it in GitHub Desktop.
Save b00gizm/176584 to your computer and use it in GitHub Desktop.
mouseDragged: function(evt) {
var info = this._mouseDownInfo;
var layout = this.get('layout');
var parentLayout = this.get('parentView').get('layout');
var loc;
// handle X direction
loc = info.left + (evt.pageX - info.pageX);
if (loc < 0) {
loc = 0;
}
else if (loc >= (parentLayout.width - layout.width)) {
loc = (parentLayout.width - layout.width);
}
this.adjust('left', loc);
// handle Y direction
loc = info.top + (evt.pageY - info.pageY);
if (loc < 0) {
loc = 0;
}
else if (loc >= (parentLayout.height - layout.height)) {
loc = (parentLayout.height - layout.height);
}
this.adjust('top', loc);
return YES;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment