Fixed fast mouse wheel zoom when approaching min/max zoom

This commit is contained in:
mourner 2011-12-02 16:27:26 +02:00
parent bd511151a0
commit 0e81d29168
2 changed files with 10 additions and 7 deletions

View File

@ -44,8 +44,9 @@ Leaflet Changelog
#### General bugfixes
* Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exagerration into account). [#331](https://github.com/CloudMade/Leaflet/issues/331)
* Fixed a bug where fast mouse wheel zoom worked incorrectly when approaching min/max zoom values.
* Fixed a bug where map panning would stuck forever after releasing the mouse over an iframe or a flash object (thanks to [@sten82](https://github.com/sten82)). [#297](https://github.com/CloudMade/Leaflet/pull/297) [#64](https://github.com/CloudMade/Leaflet/issues/64)
* Fixed a bug where mouse zoom worked incorrectly if map is inside scrolled container (partially by [@chrillo](https://github.com/chrillo)). [#206](https://github.com/CloudMade/Leaflet/issues/206)
* Fixed a bug where mouse wheel zoom worked incorrectly if map is inside scrolled container (partially by [@chrillo](https://github.com/chrillo)). [#206](https://github.com/CloudMade/Leaflet/issues/206)
* Fixed a bug where it was possible to add the same listener twice. [#281](https://github.com/CloudMade/Leaflet/issues/281)
* Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exaggeration into account). [#331](https://github.com/CloudMade/Leaflet/issues/331)
* Fixed a bug where `Marker` `setIcon` was not working properly (by [@marphi](https://github.com/marphi)). [#218](https://github.com/CloudMade/Leaflet/pull/218) [#311](https://github.com/CloudMade/Leaflet/issues/311)

View File

@ -28,18 +28,20 @@ L.Handler.ScrollWheelZoom = L.Handler.extend({
},
_performZoom: function() {
var delta = Math.round(this._delta);
var delta = Math.round(this._delta),
zoom = this._map.getZoom();
delta = Math.max(Math.min(delta, 4), -4);
delta = this._map._limitZoom(zoom + delta) - zoom;
this._delta = 0;
if (!delta) { return; }
var center = this._getCenterForScrollWheelZoom(this._lastMousePos, delta),
zoom = this._map.getZoom() + delta;
var newCenter = this._getCenterForScrollWheelZoom(this._lastMousePos, delta),
newZoom = zoom + delta;
if (this._map._limitZoom(zoom) == this._map._zoom) { return; }
this._map.setView(center, zoom);
this._map.setView(newCenter, newZoom);
},
_getCenterForScrollWheelZoom: function(mousePos, delta) {