Remove remaining static members from Interaction

This commit is contained in:
Tim Schaub
2018-02-25 12:42:37 -07:00
parent 244fbbbb8d
commit 1404e9d61d
13 changed files with 102 additions and 77 deletions

View File

@@ -3,7 +3,7 @@
*/
import {inherits} from '../index.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import Interaction from '../interaction/Interaction.js';
import Interaction, {zoomByDelta} from '../interaction/Interaction.js';
/**
* @classdesc
@@ -54,7 +54,7 @@ function handleEvent(mapBrowserEvent) {
const anchor = mapBrowserEvent.coordinate;
const delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
const view = map.getView();
Interaction.zoomByDelta(view, delta, anchor, this.duration_);
zoomByDelta(view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}

View File

@@ -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, {rotate} from '../interaction/Interaction.js';
import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction from '../interaction/Pointer.js';
/**
@@ -75,8 +75,7 @@ function handleDragEvent(mapBrowserEvent) {
if (this.lastAngle_ !== undefined) {
const delta = theta - this.lastAngle_;
const rotation = view.getRotation();
Interaction.rotateWithoutConstraints(
view, rotation - delta);
rotateWithoutConstraints(view, rotation - delta);
}
this.lastAngle_ = theta;
}

View File

@@ -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, {rotate, zoom, zoomWithoutConstraints} from '../interaction/Interaction.js';
import {rotate, rotateWithoutConstraints, zoom, zoomWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction from '../interaction/Pointer.js';
/**
@@ -87,8 +87,7 @@ function handleDragEvent(mapBrowserEvent) {
const view = map.getView();
if (view.getConstraints().rotation !== disable && this.lastAngle_ !== undefined) {
const angleDelta = theta - this.lastAngle_;
Interaction.rotateWithoutConstraints(
view, view.getRotation() - angleDelta);
rotateWithoutConstraints(view, view.getRotation() - angleDelta);
}
this.lastAngle_ = theta;
if (this.lastMagnitude_ !== undefined) {

View File

@@ -108,7 +108,7 @@ Interaction.prototype.setMap = function(map) {
* @param {ol.Coordinate} delta Delta.
* @param {number=} opt_duration Duration.
*/
Interaction.pan = function(view, delta, opt_duration) {
export function pan(view, delta, opt_duration) {
const currentCenter = view.getCenter();
if (currentCenter) {
const center = view.constrainCenter(
@@ -123,7 +123,7 @@ Interaction.pan = function(view, delta, opt_duration) {
view.setCenter(center);
}
}
};
}
/**
@@ -134,8 +134,7 @@ Interaction.pan = function(view, delta, opt_duration) {
*/
export function rotate(view, rotation, opt_anchor, opt_duration) {
rotation = view.constrainRotation(rotation, 0);
Interaction.rotateWithoutConstraints(
view, rotation, opt_anchor, opt_duration);
rotateWithoutConstraints(view, rotation, opt_anchor, opt_duration);
}
@@ -145,7 +144,7 @@ export function rotate(view, rotation, opt_anchor, opt_duration) {
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) {
export function rotateWithoutConstraints(view, rotation, opt_anchor, opt_duration) {
if (rotation !== undefined) {
const currentRotation = view.getRotation();
const currentCenter = view.getCenter();
@@ -160,7 +159,7 @@ Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_
view.rotate(rotation, opt_anchor);
}
}
};
}
/**
@@ -189,7 +188,7 @@ export function zoom(view, resolution, opt_anchor, opt_duration, opt_direction)
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
const currentResolution = view.getResolution();
let resolution = view.constrainResolution(currentResolution, delta, 0);
@@ -218,7 +217,7 @@ Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
}
zoomWithoutConstraints(view, resolution, opt_anchor, opt_duration);
};
}
/**

View File

@@ -6,7 +6,7 @@ import {rotate as rotateCoordinate} from '../coordinate.js';
import EventType from '../events/EventType.js';
import KeyCode from '../events/KeyCode.js';
import {noModifierKeys, targetNotEditable} from '../events/condition.js';
import Interaction from '../interaction/Interaction.js';
import Interaction, {pan} from '../interaction/Interaction.js';
/**
* @classdesc
@@ -100,7 +100,7 @@ function handleEvent(mapBrowserEvent) {
}
const delta = [deltaX, deltaY];
rotateCoordinate(delta, view.getRotation());
Interaction.pan(view, delta, this.duration_);
pan(view, delta, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import EventType from '../events/EventType.js';
import {targetNotEditable} from '../events/condition.js';
import Interaction from '../interaction/Interaction.js';
import Interaction, {zoomByDelta} from '../interaction/Interaction.js';
/**
* @classdesc
@@ -73,8 +73,7 @@ function handleEvent(mapBrowserEvent) {
const map = mapBrowserEvent.map;
const delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
const view = map.getView();
Interaction.zoomByDelta(
view, delta, undefined, this.duration_);
zoomByDelta(view, delta, undefined, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}

View File

@@ -7,7 +7,7 @@ import {always} from '../events/condition.js';
import {easeOut} from '../easing.js';
import EventType from '../events/EventType.js';
import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../has.js';
import Interaction from '../interaction/Interaction.js';
import Interaction, {zoomByDelta} from '../interaction/Interaction.js';
import {clamp} from '../math.js';
@@ -280,8 +280,7 @@ MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
}
const maxDelta = MAX_DELTA;
const delta = clamp(this.delta_, -maxDelta, maxDelta);
Interaction.zoomByDelta(view, -delta, this.lastAnchor_,
this.duration_);
zoomByDelta(view, -delta, this.lastAnchor_, this.duration_);
this.mode_ = undefined;
this.delta_ = 0;
this.lastAnchor_ = null;

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import ViewHint from '../ViewHint.js';
import {FALSE} from '../functions.js';
import Interaction, {rotate} from '../interaction/Interaction.js';
import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js';
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
import {disable} from '../rotationconstraint.js';
@@ -114,8 +114,7 @@ function handleDragEvent(mapBrowserEvent) {
if (this.rotating_) {
const rotation = view.getRotation();
map.render();
Interaction.rotateWithoutConstraints(view,
rotation + rotationDelta, this.anchor_);
rotateWithoutConstraints(view, rotation + rotationDelta, this.anchor_);
}
}