Merge pull request #294 from fredj/stopped-map-events

can't listen to mousedown/touchstart on map div
This commit is contained in:
Frédéric Junod
2012-07-02 13:44:06 -07:00
6 changed files with 70 additions and 24 deletions

View File

@@ -167,11 +167,7 @@ OpenLayers.Event = {
stop: function(event, allowDefault) {
if (!allowDefault) {
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
OpenLayers.Event.preventDefault(event);
}
if (event.stopPropagation) {
@@ -181,6 +177,22 @@ OpenLayers.Event = {
}
},
/**
* Method: preventDefault
* Cancels the event if it is cancelable, without stopping further
* propagation of the event.
*
* Parameters:
* event - {Event}
*/
preventDefault: function(event) {
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
},
/**
* Method: findElement
*

View File

@@ -172,7 +172,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
this.down(evt);
this.callback("down", [evt.xy]);
OpenLayers.Event.stop(evt);
// prevent document dragging
OpenLayers.Event.preventDefault(evt);
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart ?

View File

@@ -103,7 +103,7 @@ OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {
this.last = null;
}
// prevent document dragging
OpenLayers.Event.stop(evt);
OpenLayers.Event.preventDefault(evt);
return propagate;
},

View File

@@ -284,7 +284,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
node.setAttributeNS(null, "height", height);
node.setAttributeNS(this.xlinkns, "href", style.externalGraphic);
node.setAttributeNS(null, "style", "opacity: "+opacity);
node.onclick = OpenLayers.Renderer.SVG.preventDefault;
node.onclick = OpenLayers.Event.preventDefault;
} else if (this.isComplexSymbol(style.graphicName)) {
// the symbol viewBox is three times as large as the symbol
var offset = style.pointRadius * 3;
@@ -1000,9 +1000,10 @@ OpenLayers.Renderer.SVG.LABEL_VFACTOR = {
/**
* Function: OpenLayers.Renderer.SVG.preventDefault
* *Deprecated*. Use <OpenLayers.Event.preventDefault> method instead.
* Used to prevent default events (especially opening images in a new tab on
* ctrl-click) from being executed for externalGraphic symbols
*/
OpenLayers.Renderer.SVG.preventDefault = function(e) {
e.preventDefault && e.preventDefault();
OpenLayers.Event.preventDefault(e);
};