Make the drag handler only call done if it actually dragged - thanks for the review Eric (closes #1118).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5097 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-11-01 20:53:06 +00:00
parent 756f6ca24d
commit ba8354b593
2 changed files with 20 additions and 4 deletions

View File

@@ -16,7 +16,9 @@
* when the drag begins, with each move, and when the drag is done. In
* addition, controls can have callbacks keyed to 'up' and 'out' if they
* care to differentiate between the types of events that correspond with
* the end of a drag sequence.
* the end of a drag sequence. If no drag actually occurs (no mouse move)
* the 'down' and 'up' callbacks will be called, but not the 'done'
* callback.
*
* Create a new drag handler with the <OpenLayers.Handler.Drag> constructor.
*
@@ -207,13 +209,16 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
*/
mouseup: function (evt) {
if (this.started) {
var dragged = (this.start != this.last);
this.started = false;
this.dragging = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "";
this.up(evt);
this.callback("up", [evt.xy]);
this.callback("done", [evt.xy]);
if(dragged) {
this.callback("done", [evt.xy]);
}
document.onselectstart = this.oldOnselectstart;
}
return true;
@@ -231,16 +236,19 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
*/
mouseout: function (evt) {
if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
var dragged = (this.start != this.last);
this.started = false;
this.dragging = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "";
this.out(evt);
this.callback("out", []);
if(dragged) {
this.callback("done", [evt.xy]);
}
if(document.onselectstart) {
document.onselectstart = this.oldOnselectstart;
}
this.callback("done", [evt.xy]);
}
return true;
},