Let the controls decide about stopPropagation and preventDefault.

This commit is contained in:
ahocevar
2012-06-24 19:53:42 +02:00
parent 68498bc36e
commit d8599f28b9
3 changed files with 10 additions and 4 deletions

View File

@@ -63,6 +63,8 @@ ol.control.Navigation.prototype.zoomMap = function(evt) {
return;
}
map.setZoom(map.getZoom()-delta, map.getEvents().getPointerPosition(evt));
// We don't want the page to scroll.
evt.preventDefault();
return false;
};

View File

@@ -91,6 +91,13 @@ ol.control.Zoom.prototype.handle = function(evt) {
this.map_.zoomOut();
handled = true;
}
if (handled) {
// Stop default behavior (i.e. don't follow link to anchor)
evt.preventDefault();
// On Android 2.3, the above does not prevent the link from being
// followed, but stopPropagation does.
evt.stopPropagation();
}
}
return !handled;
};