With Erik's approval on #341, I'm happy with this. This restores the
mousewheel functionality we had in earlier releases in a similar way, rewritten for handlers. (The benefit of handlers in this case is that handlers are write-once, use many, so the next mousewheel thing we get will *also* be able to use this code.) git-svn-id: http://svn.openlayers.org/trunk/openlayers@2877 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -59,20 +59,33 @@ OpenLayers.Control.Navigation.prototype =
|
||||
return false;
|
||||
},
|
||||
|
||||
wheelChange: function(evt, deltaZ) {
|
||||
var newZoom = this.map.getZoom() + deltaZ;
|
||||
if (!this.map.isValidZoomLevel(newZoom)) return;
|
||||
|
||||
var size = this.map.getSize();
|
||||
var deltaX = size.w/2 - evt.xy.x;
|
||||
var deltaY = evt.xy.y - size.h/2;
|
||||
var newRes = this.map.baseLayer.resolutions[newZoom];
|
||||
var zoomPoint = this.map.getLonLatFromPixel(evt.xy);
|
||||
var newCenter = new OpenLayers.LonLat(
|
||||
zoomPoint.lon + deltaX * newRes,
|
||||
zoomPoint.lat + deltaY * newRes );
|
||||
this.map.setCenter( newCenter, newZoom );
|
||||
},
|
||||
|
||||
/** User spun scroll wheel up
|
||||
*
|
||||
*/
|
||||
wheelUp: function(evt) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
|
||||
this.map.getZoom() + 1);
|
||||
this.wheelChange(evt, 1);
|
||||
},
|
||||
|
||||
/** User spun scroll wheel down
|
||||
*
|
||||
*/
|
||||
wheelDown: function(evt) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
|
||||
this.map.getZoom() - 1);
|
||||
this.wheelChange(evt, -1);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
Reference in New Issue
Block a user