Allow for using a different set of default behaviors.
The default behavior of dragging and wheel zooming feels specific to 2D maps. So I think it makes sense to introduce a special type of controls (ol.control.DefaultControl) that implement default behaviors. This change also re-introduces the Navigatin control, which is a container for the default behaviors that were previously defined in the map handlers. Maybe this control needs to be renamed to Navigatin2D in the future, and there could be a different Navigation control for 3D maps.
This commit is contained in:
+6
-12
@@ -95,25 +95,19 @@ ol.handler.Drag.prototype.handleDragStart = function(e) {
|
||||
ol.handler.Drag.prototype.handleDrag = function(e) {
|
||||
this.states_.dragged = true;
|
||||
var newE = new ol.events.MapEvent(ol.events.MapEventType.DRAG, e);
|
||||
newE.delementaX = e.clientX - this.prevX_;
|
||||
newE.delementaY = e.clientY - this.prevY_;
|
||||
newE.deltaX = e.clientX - this.prevX_;
|
||||
newE.deltaY = e.clientY - this.prevY_;
|
||||
this.prevX_ = e.clientX;
|
||||
this.prevY_ = e.clientY;
|
||||
var rt = goog.events.dispatchEvent(this.map_, newE);
|
||||
if (rt) {
|
||||
this.defaultDrag(newE);
|
||||
var defaultControl = this.map_.getDefaultControl();
|
||||
if (defaultControl) {
|
||||
defaultControl.defaultDrag(newE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.events.MapEvent} e
|
||||
*/
|
||||
ol.handler.Drag.prototype.defaultDrag = function(e) {
|
||||
var delementaX = /** @type {number} */ e.delementaX;
|
||||
var delementaY = /** @type {number} */ e.delementaY;
|
||||
this.map_.moveByViewportPx(delementaX, delementaY);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {goog.fx.DragEvent} e
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user