Nice improvement of the wheel zooming experience.
This commit is contained in:
@@ -20,6 +20,12 @@ ol.control.Navigation = function(opt_autoActivate) {
|
|||||||
this.autoActivate_ =
|
this.autoActivate_ =
|
||||||
goog.isDef(opt_autoActivate) ? opt_autoActivate : true;
|
goog.isDef(opt_autoActivate) ? opt_autoActivate : true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number?}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.zoomBlocked_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.Navigation, ol.control.Control);
|
goog.inherits(ol.control.Navigation, ol.control.Control);
|
||||||
|
|
||||||
@@ -57,12 +63,17 @@ ol.control.Navigation.prototype.moveMap = function(evt) {
|
|||||||
* @param {Event} evt
|
* @param {Event} evt
|
||||||
*/
|
*/
|
||||||
ol.control.Navigation.prototype.zoomMap = function(evt) {
|
ol.control.Navigation.prototype.zoomMap = function(evt) {
|
||||||
var map = this.map_,
|
var me = this;
|
||||||
delta = ((evt.deltaY / 3) | 0);
|
if (evt.deltaY === 0 || me.zoomBlocked_) {
|
||||||
if (Math.abs(delta) === 0) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
me.zoomBlocked_ = window.setTimeout(function() {
|
||||||
map.setZoom(map.getZoom()-delta, map.getEvents().getPointerPosition(evt));
|
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.
|
// We don't want the page to scroll.
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user