Skip to content

Commit

Permalink
Merge pull request #2836 from AndreyGeonya/master
Browse files Browse the repository at this point in the history
#2501, optional wheel debounce time
  • Loading branch information
mourner committed Aug 5, 2014
2 parents b80c9b3 + a321406 commit a3066bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/map/handler/Map.ScrollWheelZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*/

L.Map.mergeOptions({
scrollWheelZoom: true
scrollWheelZoom: true,
wheelDebounceTime: 40
});

L.Map.ScrollWheelZoom = L.Handler.extend({
Expand All @@ -25,6 +26,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({

_onWheelScroll: function (e) {
var delta = L.DomEvent.getWheelDelta(e);
var debounce = this._map.options.wheelDebounceTime;

this._delta += delta;
this._lastMousePos = this._map.mouseEventToContainerPoint(e);
Expand All @@ -33,7 +35,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
this._startTime = +new Date();
}

var left = Math.max(40 - (+new Date() - this._startTime), 0);
var left = Math.max(debounce - (+new Date() - this._startTime), 0);

clearTimeout(this._timer);
this._timer = setTimeout(L.bind(this._performZoom, this), left);
Expand Down

0 comments on commit a3066bd

Please sign in to comment.