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:
ahocevar
2012-07-12 20:51:47 +02:00
parent 42c4c9d869
commit 3cc069186c
8 changed files with 141 additions and 40 deletions
+6 -12
View File
@@ -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
*/