Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2501, optional wheel debounce time #2836

Merged
merged 2 commits into from
Aug 5, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
#2501, wheelDebounceTime option added
  • Loading branch information
andriiheonia committed Aug 5, 2014
commit f5cfddb60d174f1f8d098ca4257f84695e31e0c2
8 changes: 5 additions & 3 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 @@ -24,7 +25,8 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
},

_onWheelScroll: function (e) {
var delta = L.DomEvent.getWheelDelta(e);
var delta = L.DomEvent.getWheelDelta(e),
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