Merge branch 'master' into event

Conflicts:
	src/ol/Map.js
	src/ol/event/Drag.js
This commit is contained in:
Éric Lemoine
2012-07-09 08:57:55 +02:00
14 changed files with 670 additions and 381 deletions

View File

@@ -20,6 +20,12 @@ ol.control.Navigation = function(opt_autoActivate) {
this.autoActivate_ =
goog.isDef(opt_autoActivate) ? opt_autoActivate : true;
/**
* @type {number?}
* @private
*/
this.zoomBlocked_ = null;
};
goog.inherits(ol.control.Navigation, ol.control.Control);
@@ -52,7 +58,7 @@ ol.control.Navigation.prototype.deactivate = function() {
* @param {Object} evt
*/
ol.control.Navigation.prototype.moveMap = function(evt) {
this.map_.moveByPx(evt.deltaX, evt.deltaY);
this.map_.moveByViewportPx(evt.deltaX, evt.deltaY);
return false;
};
@@ -60,12 +66,17 @@ ol.control.Navigation.prototype.moveMap = function(evt) {
* @param {Event} evt
*/
ol.control.Navigation.prototype.zoomMap = function(evt) {
var map = this.map_,
delta = ((evt.deltaY / 3) | 0);
if (Math.abs(delta) === 0) {
var me = this;
if (evt.deltaY === 0 || me.zoomBlocked_) {
return;
}
map.setZoom(map.getZoom()-delta, map.getEvents().getPointerPosition(evt));
me.zoomBlocked_ = window.setTimeout(function() {
me.zoomBlocked_ = null;
}, 200);
var map = me.map_,
step = evt.deltaY / Math.abs(evt.deltaY);
map.setZoom(map.getZoom()-step, map.getEvents().getPointerPosition(evt));
// We don't want the page to scroll.
evt.preventDefault();
return false;