#774 - drag control only calls move callback with a change in pixel position - DragPan control simplified

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3891 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-11 03:32:41 +00:00
parent 4de7f79d45
commit b4da05da35
3 changed files with 34 additions and 35 deletions

View File

@@ -39,10 +39,10 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
dragging: false,
/**
* Property: start
* Property: last
* {<OpenLayers.Pixel>}
*/
start: null,
last: null,
/**
* Property: oldOnselectstart
@@ -90,7 +90,7 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
this.started = true;
this.dragging = false;
this.start = evt.xy.clone();
this.last = evt.xy;
// TBD replace with CSS classes
this.map.div.style.cursor = "move";
this.callback("down", [evt.xy]);
@@ -112,11 +112,14 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
*/
mousemove: function (evt) {
if (this.started) {
this.dragging = true;
this.callback("move", [evt.xy]);
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart;
document.onselectstart = function() {return false;}
if(evt.xy.x != this.last.x || evt.xy.y != this.last.y) {
this.dragging = true;
this.callback("move", [evt.xy]);
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart;
document.onselectstart = function() {return false;}
}
this.last = evt.xy;
}
}
return true;
@@ -135,6 +138,7 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
mouseup: function (evt) {
if (this.started) {
this.started = false;
this.dragging = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "";
this.callback("up", [evt.xy]);