View / implemented begin- and endInteraction methods

This commit is contained in:
Olivier Guyot
2019-01-06 10:46:52 +01:00
parent 1cb934dbe3
commit 4e1ece16ed
9 changed files with 47 additions and 14 deletions

View File

@@ -76,7 +76,7 @@ class DragPan extends PointerInteraction {
handleDragEvent(mapBrowserEvent) {
if (!this.panning_) {
this.panning_ = true;
this.getMap().getView().setHint(ViewHint.INTERACTING, 1);
this.getMap().getView().beginInteraction();
}
const targetPointers = this.targetPointers;
const centroid = centroidFromPointers(targetPointers);
@@ -129,7 +129,7 @@ class DragPan extends PointerInteraction {
}
if (this.panning_) {
this.panning_ = false;
view.setHint(ViewHint.INTERACTING, -1);
view.endInteraction();
}
return false;
} else {

View File

@@ -97,7 +97,7 @@ class DragRotate extends PointerInteraction {
const map = mapBrowserEvent.map;
const view = map.getView();
view.setHint(ViewHint.INTERACTING, -1);
view.endInteraction();
const rotation = view.getRotation();
rotate(view, rotation, undefined, this.duration_);
return false;
@@ -114,7 +114,7 @@ class DragRotate extends PointerInteraction {
if (mouseActionButton(mapBrowserEvent) && this.condition_(mapBrowserEvent)) {
const map = mapBrowserEvent.map;
map.getView().setHint(ViewHint.INTERACTING, 1);
map.getView().beginInteraction();
this.lastAngle_ = undefined;
return true;
} else {

View File

@@ -113,7 +113,7 @@ class DragRotateAndZoom extends PointerInteraction {
const map = mapBrowserEvent.map;
const view = map.getView();
view.setHint(ViewHint.INTERACTING, -1);
view.endInteraction();
const direction = this.lastScaleDelta_ - 1;
rotate(view, view.getRotation());
zoom(view, view.getResolution(), undefined, this.duration_, direction);
@@ -130,7 +130,7 @@ class DragRotateAndZoom extends PointerInteraction {
}
if (this.condition_(mapBrowserEvent)) {
mapBrowserEvent.map.getView().setHint(ViewHint.INTERACTING, 1);
mapBrowserEvent.map.getView().beginInteraction();
this.lastAngle_ = undefined;
this.lastMagnitude_ = undefined;
return true;

View File

@@ -152,7 +152,7 @@ class MouseWheelZoom extends Interaction {
decrementInteractingHint_() {
this.trackpadTimeoutId_ = undefined;
const view = this.getMap().getView();
view.setHint(ViewHint.INTERACTING, -1);
view.endInteraction();
}
/**
@@ -218,7 +218,7 @@ class MouseWheelZoom extends Interaction {
if (this.trackpadTimeoutId_) {
clearTimeout(this.trackpadTimeoutId_);
} else {
view.setHint(ViewHint.INTERACTING, 1);
view.beginInteraction();
}
this.trackpadTimeoutId_ = setTimeout(this.decrementInteractingHint_.bind(this), this.trackpadEventGap_);
let resolution = view.getResolution() * Math.pow(2, delta / this.trackpadDeltaPerZoom_);

View File

@@ -131,7 +131,7 @@ class PinchRotate extends PointerInteraction {
if (this.targetPointers.length < 2) {
const map = mapBrowserEvent.map;
const view = map.getView();
view.setHint(ViewHint.INTERACTING, -1);
view.endInteraction();
if (this.rotating_) {
const rotation = view.getRotation();
rotate(view, rotation, this.anchor_, this.duration_);
@@ -153,7 +153,7 @@ class PinchRotate extends PointerInteraction {
this.rotating_ = false;
this.rotationDelta_ = 0.0;
if (!this.handlingDownUpSequence) {
map.getView().setHint(ViewHint.INTERACTING, 1);
map.getView().beginInteraction();
}
return true;
} else {

View File

@@ -126,7 +126,7 @@ class PinchZoom extends PointerInteraction {
if (this.targetPointers.length < 2) {
const map = mapBrowserEvent.map;
const view = map.getView();
view.setHint(ViewHint.INTERACTING, -1);
view.endInteraction();
const resolution = view.getResolution();
if (this.constrainResolution_ ||
resolution < view.getMinResolution() ||
@@ -153,7 +153,7 @@ class PinchZoom extends PointerInteraction {
this.lastDistance_ = undefined;
this.lastScaleDelta_ = 1;
if (!this.handlingDownUpSequence) {
map.getView().setHint(ViewHint.INTERACTING, 1);
map.getView().beginInteraction();
}
return true;
} else {