Cancel and restart animation when wheel zooming
This commit is contained in:
@@ -192,8 +192,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
var timeLeft = Math.max(this.timeout_ - (now - this.startTime_), 0);
|
var timeLeft = Math.max(this.timeout_ - (now - this.startTime_), 0);
|
||||||
|
|
||||||
clearTimeout(this.timeoutId_);
|
clearTimeout(this.timeoutId_);
|
||||||
this.timeoutId_ = setTimeout(
|
this.timeoutId_ = setTimeout(this.handleWheelZoom_.bind(this, map), timeLeft);
|
||||||
this.doZoom_.bind(this, map), timeLeft);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -203,14 +202,15 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
|||||||
* @private
|
* @private
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol.Map} map Map.
|
||||||
*/
|
*/
|
||||||
ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
|
ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
if (!view.getAnimating()) {
|
if (view.getAnimating()) {
|
||||||
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
|
view.cancelAnimations();
|
||||||
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
|
||||||
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
|
||||||
this.duration_);
|
|
||||||
}
|
}
|
||||||
|
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
|
||||||
|
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
||||||
|
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
||||||
|
this.duration_);
|
||||||
this.mode_ = undefined;
|
this.mode_ = undefined;
|
||||||
this.delta_ = 0;
|
this.delta_ = 0;
|
||||||
this.lastAnchor_ = null;
|
this.lastAnchor_ = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user