Add new container which don't stop event propagation

and allow overlays to optionnally stop event propagation
This commit is contained in:
Bruno Binet
2013-10-11 11:12:36 +02:00
parent 8c8dbe2ece
commit caf958826d
2 changed files with 32 additions and 6 deletions

View File

@@ -225,13 +225,21 @@ ol.Map = function(options) {
*/
this.overlayContainer_ = goog.dom.createDom(goog.dom.TagName.DIV,
'ol-overlaycontainer');
goog.events.listen(this.overlayContainer_, [
goog.dom.appendChild(this.viewport_, this.overlayContainer_);
/**
* @private
* @type {Element}
*/
this.overlayContainerStopEvent_ = goog.dom.createDom(goog.dom.TagName.DIV,
'ol-overlaycontainer-stopevent');
goog.events.listen(this.overlayContainerStopEvent_, [
goog.events.EventType.CLICK,
goog.events.EventType.DBLCLICK,
ol.BrowserFeature.HAS_TOUCH ?
goog.events.EventType.TOUCHSTART : goog.events.EventType.MOUSEDOWN
], goog.events.Event.stopPropagation);
goog.dom.appendChild(this.viewport_, this.overlayContainer_);
goog.dom.appendChild(this.viewport_, this.overlayContainerStopEvent_);
var mapBrowserEventHandler = new ol.MapBrowserEventHandler(this);
goog.events.listen(mapBrowserEventHandler,
@@ -591,14 +599,24 @@ ol.Map.prototype.getViewport = function() {
/**
* @return {Element} The map's overlay container. Elements added to this
* container won't let mousedown and touchstart events through to the map, so
* clicks and gestures on an overlay don't trigger any MapBrowserEvent.
* container will let mousedown and touchstart events through to the map, so
* clicks and gestures on an overlay will trigger MapBrowserEvent events.
*/
ol.Map.prototype.getOverlayContainer = function() {
return this.overlayContainer_;
};
/**
* @return {Element} The map's overlay container. Elements added to this
* container won't let mousedown and touchstart events through to the map, so
* clicks and gestures on an overlay don't trigger any MapBrowserEvent.
*/
ol.Map.prototype.getOverlayContainerStopEvent = function() {
return this.overlayContainerStopEvent_;
};
/**
* @param {ol.Tile} tile Tile.
* @param {string} tileSourceKey Tile source key.