use the mousewheel handler

This commit is contained in:
Éric Lemoine
2012-07-09 09:28:56 +02:00
parent 2c61e16b55
commit 9e693f29c5
2 changed files with 17 additions and 5 deletions

View File

@@ -38,7 +38,7 @@ ol.control.Navigation.prototype.activate = function() {
// navigation control.
var target = this.map_.getParentEventTarget();
goog.events.listen(target, 'drag', this.moveMap, false, this);
goog.events.listen(target, 'scroll', this.zoomMap, false, this);
goog.events.listen(target, 'mousewheel', this.zoomMap, false, this);
}
return active;
};
@@ -49,7 +49,7 @@ ol.control.Navigation.prototype.deactivate = function() {
if (inactive) {
var target = this.map_.getParentEventTarget();
goog.events.unlisten(target, 'drag', this.moveMap, false, this);
goog.events.unlisten(target, 'scroll', this.zoomMap, false, this);
goog.events.unlisten(target, 'mousewheel', this.zoomMap, false, this);
}
return inactive;
};
@@ -76,7 +76,7 @@ ol.control.Navigation.prototype.zoomMap = function(evt) {
var map = me.map_,
step = evt.deltaY / Math.abs(evt.deltaY);
map.setZoom(map.getZoom()-step, map.getEvents().getPointerPosition(evt));
map.setZoom(map.getZoom()-step, evt.position);
// We don't want the page to scroll.
evt.preventDefault();
return false;