Ticket #341: 341.patch
| File 341.patch, 2.9 kB (added by sderle, 2 years ago) |
|---|
-
lib/OpenLayers/Control/Navigation.js
old new 59 59 return false; 60 60 }, 61 61 62 wheelChange: function(evt, deltaZ) { 63 var newZoom = this.map.getZoom() + deltaZ; 64 if (!this.map.isValidZoomLevel(newZoom)) return; 65 66 var size = this.map.getSize(); 67 var deltaX = size.w/2 - evt.xy.x; 68 var deltaY = evt.xy.y - size.h/2; 69 var newRes = this.map.baseLayer.resolutions[newZoom]; 70 var zoomPoint = this.map.getLonLatFromPixel(evt.xy); 71 var newCenter = new OpenLayers.LonLat( 72 zoomPoint.lon + deltaX * newRes, 73 zoomPoint.lat + deltaY * newRes ); 74 this.map.setCenter( newCenter, newZoom ); 75 }, 76 62 77 /** User spun scroll wheel up 63 78 * 64 79 */ 65 80 wheelUp: function(evt) { 66 this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), 67 this.map.getZoom() + 1); 81 this.wheelChange(evt, 1); 68 82 }, 69 83 70 84 /** User spun scroll wheel down 71 85 * 72 86 */ 73 87 wheelDown: function(evt) { 74 this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), 75 this.map.getZoom() - 1); 88 this.wheelChange(evt, -1); 76 89 }, 77 90 78 91 /** @final @type String */ -
lib/OpenLayers/Handler/MouseWheel.js
old new 13 13 /** @type function **/ 14 14 wheelListener: null, 15 15 16 /** @type OpenLayers.Pixel 17 * @private 18 * 19 * mousePosition is necessary because evt.clientX/Y is buggy in Moz on 20 * wheel events, so we cache and use the value from the last mousemove. 21 **/ 22 mousePosition: null, 23 16 24 /** 17 25 * @constructor 18 26 * … … 68 76 // add the mouse position to the event because mozilla has a bug 69 77 // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179) 70 78 // getLonLatFromViewPortPx(e) returns wrong values 71 // TODO FIXME FIXME this might not be the right way to port the 2.3 behavior 72 e.xy = this.map.events.getMousePosition(e); 79 e.xy = this.mousePosition; 73 80 if (delta < 0) { 74 81 this.callback("down", [e, delta]); 75 82 } else { … … 82 89 } 83 90 }, 84 91 92 mousemove: function (evt) { 93 this.mousePosition = evt.xy; 94 }, 95 85 96 activate: function (evt) { 86 97 OpenLayers.Handler.prototype.activate.apply(this, arguments); 87 98 //register mousewheel events specifically on the window and document
