View / implemented begin- and endInteraction methods
This commit is contained in:
@@ -1201,6 +1201,22 @@ class View extends BaseObject {
|
||||
this.cancelAnimations();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the View that an interaction has started.
|
||||
* @api
|
||||
*/
|
||||
beginInteraction() {
|
||||
this.setHint(ViewHint.INTERACTING, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the View that an interaction has ended.
|
||||
* @api
|
||||
*/
|
||||
endInteraction() {
|
||||
this.setHint(ViewHint.INTERACTING, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ class ZoomSlider extends Control {
|
||||
*/
|
||||
handleDraggerStart_(event) {
|
||||
if (!this.dragging_ && event.originalEvent.target === this.element.firstElementChild) {
|
||||
this.getMap().getView().setHint(ViewHint.INTERACTING, 1);
|
||||
this.getMap().getView().beginInteraction();
|
||||
this.previousX_ = event.clientX;
|
||||
this.previousY_ = event.clientY;
|
||||
this.dragging_ = true;
|
||||
@@ -279,7 +279,7 @@ class ZoomSlider extends Control {
|
||||
handleDraggerEnd_(event) {
|
||||
if (this.dragging_) {
|
||||
const view = this.getMap().getView();
|
||||
view.setHint(ViewHint.INTERACTING, -1);
|
||||
view.endInteraction();
|
||||
|
||||
view.animate({
|
||||
resolution: view.constrainResolution(this.currentResolution_),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user