Remove some of the static members from Interaction
This commit is contained in:
@@ -6,7 +6,7 @@ import {disable} from '../rotationconstraint.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import {altShiftKeysOnly, mouseOnly, mouseActionButton} from '../events/condition.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import Interaction, {rotate} from '../interaction/Interaction.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
|
||||
/**
|
||||
@@ -96,8 +96,7 @@ function handleUpEvent(mapBrowserEvent) {
|
||||
const view = map.getView();
|
||||
view.setHint(ViewHint.INTERACTING, -1);
|
||||
const rotation = view.getRotation();
|
||||
Interaction.rotate(view, rotation,
|
||||
undefined, this.duration_);
|
||||
rotate(view, rotation, undefined, this.duration_);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import {disable} from '../rotationconstraint.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import {shiftKeyOnly, mouseOnly} from '../events/condition.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import Interaction, {rotate, zoom, zoomWithoutConstraints} from '../interaction/Interaction.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ function handleDragEvent(mapBrowserEvent) {
|
||||
this.lastAngle_ = theta;
|
||||
if (this.lastMagnitude_ !== undefined) {
|
||||
const resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
|
||||
Interaction.zoomWithoutConstraints(view, resolution);
|
||||
zoomWithoutConstraints(view, resolution);
|
||||
}
|
||||
if (this.lastMagnitude_ !== undefined) {
|
||||
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
|
||||
@@ -116,9 +116,8 @@ function handleUpEvent(mapBrowserEvent) {
|
||||
const view = map.getView();
|
||||
view.setHint(ViewHint.INTERACTING, -1);
|
||||
const direction = this.lastScaleDelta_ - 1;
|
||||
Interaction.rotate(view, view.getRotation());
|
||||
Interaction.zoom(view, view.getResolution(),
|
||||
undefined, this.duration_, direction);
|
||||
rotate(view, view.getRotation());
|
||||
zoom(view, view.getResolution(), undefined, this.duration_, direction);
|
||||
this.lastScaleDelta_ = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,11 +132,11 @@ Interaction.pan = function(view, delta, opt_duration) {
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
Interaction.rotate = function(view, rotation, opt_anchor, opt_duration) {
|
||||
export function rotate(view, rotation, opt_anchor, opt_duration) {
|
||||
rotation = view.constrainRotation(rotation, 0);
|
||||
Interaction.rotateWithoutConstraints(
|
||||
view, rotation, opt_anchor, opt_duration);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -177,11 +177,10 @@ Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_
|
||||
* will select the nearest resolution. If not defined 0 is
|
||||
* assumed.
|
||||
*/
|
||||
Interaction.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) {
|
||||
export function zoom(view, resolution, opt_anchor, opt_duration, opt_direction) {
|
||||
resolution = view.constrainResolution(resolution, 0, opt_direction);
|
||||
Interaction.zoomWithoutConstraints(
|
||||
view, resolution, opt_anchor, opt_duration);
|
||||
};
|
||||
zoomWithoutConstraints(view, resolution, opt_anchor, opt_duration);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -218,8 +217,7 @@ Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
|
||||
];
|
||||
}
|
||||
|
||||
Interaction.zoomWithoutConstraints(
|
||||
view, resolution, opt_anchor, opt_duration);
|
||||
zoomWithoutConstraints(view, resolution, opt_anchor, opt_duration);
|
||||
};
|
||||
|
||||
|
||||
@@ -229,7 +227,7 @@ Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
Interaction.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) {
|
||||
export function zoomWithoutConstraints(view, resolution, opt_anchor, opt_duration) {
|
||||
if (resolution) {
|
||||
const currentResolution = view.getResolution();
|
||||
const currentCenter = view.getCenter();
|
||||
@@ -249,5 +247,6 @@ Interaction.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_
|
||||
view.setResolution(resolution);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Interaction;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import Interaction, {rotate} from '../interaction/Interaction.js';
|
||||
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
|
||||
import {disable} from '../rotationconstraint.js';
|
||||
|
||||
@@ -132,8 +132,7 @@ function handleUpEvent(mapBrowserEvent) {
|
||||
view.setHint(ViewHint.INTERACTING, -1);
|
||||
if (this.rotating_) {
|
||||
const rotation = view.getRotation();
|
||||
Interaction.rotate(
|
||||
view, rotation, this.anchor_, this.duration_);
|
||||
rotate(view, rotation, this.anchor_, this.duration_);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import {zoom, zoomWithoutConstraints} from '../interaction/Interaction.js';
|
||||
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ function handleDragEvent(mapBrowserEvent) {
|
||||
|
||||
// scale, bypass the resolution constraint
|
||||
map.render();
|
||||
Interaction.zoomWithoutConstraints(view, newResolution, this.anchor_);
|
||||
zoomWithoutConstraints(view, newResolution, this.anchor_);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@ function handleUpEvent(mapBrowserEvent) {
|
||||
// direction not to zoom out/in if user was pinching in/out.
|
||||
// Direction is > 0 if pinching out, and < 0 if pinching in.
|
||||
const direction = this.lastScaleDelta_ - 1;
|
||||
Interaction.zoom(view, resolution,
|
||||
this.anchor_, this.duration_, direction);
|
||||
zoom(view, resolution, this.anchor_, this.duration_, direction);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user