No trackpad mode for constrained resolutions

This commit is contained in:
Andreas Hocevar
2020-02-16 10:05:32 +01:00
parent 5150378983
commit d93073f8d0
2 changed files with 10 additions and 5 deletions

View File

@@ -793,6 +793,13 @@ class View extends BaseObject {
return this.constraints_;
}
/**
* @return {boolean} Resolution constraint is set
*/
getConstrainResolution() {
return this.options_.constrainResolution;
}
/**
* @param {Array<number>=} opt_hints Destination array.
* @return {Array<number>} Hint.

View File

@@ -212,8 +212,8 @@ class MouseWheelZoom extends Interaction {
Mode.WHEEL;
}
if (this.mode_ === Mode.TRACKPAD) {
const view = map.getView();
const view = map.getView();
if (this.mode_ === Mode.TRACKPAD && !view.getConstrainResolution()) {
if (this.trackpadTimeoutId_) {
clearTimeout(this.trackpadTimeoutId_);
} else {
@@ -248,9 +248,7 @@ class MouseWheelZoom extends Interaction {
view.cancelAnimations();
}
let delta = -clamp(this.totalDelta_, -this.maxDelta_ * this.deltaPerZoom_, this.maxDelta_ * this.deltaPerZoom_) / this.deltaPerZoom_;
const currentZoom = view.getZoom();
const newZoom = view.getConstrainedZoom(currentZoom + delta);
if (currentZoom === newZoom) {
if (view.getConstrainResolution()) {
// view has a zoom constraint, zoom by 1
delta = delta ? delta > 0 ? 1 : -1 : 0;
}