Add new timeout option to ol.interaction.MouseWheelZoom

And remove the `ol.MOUSEWHEELZOOM_TIMEOUT_DURATION` define.
This commit is contained in:
Frederic Junod
2016-10-28 09:07:37 +02:00
parent 7834a95210
commit e0a9910d4e
4 changed files with 46 additions and 8 deletions

View File

@@ -36,6 +36,12 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
*/
this.duration_ = options.duration !== undefined ? options.duration : 250;
/**
* @private
* @type {number}
*/
this.timeout_ = options.timeout !== undefined ? options.timeout : 80;
/**
* @private
* @type {boolean}
@@ -109,8 +115,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.startTime_ = Date.now();
}
var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION;
var timeLeft = Math.max(duration - (Date.now() - this.startTime_), 0);
var timeLeft = Math.max(this.timeout_ - (Date.now() - this.startTime_), 0);
clearTimeout(this.timeoutId_);
this.timeoutId_ = setTimeout(