View / removed the constrainRotation method

This commit is contained in:
jahow
2019-01-12 15:41:20 +01:00
committed by Olivier Guyot
parent e6c4b2ffd1
commit c2c1aa01d3
5 changed files with 7 additions and 31 deletions

View File

@@ -681,7 +681,7 @@ class View extends BaseObject {
* @param {number=} opt_delta Delta. Default is `0`.
* @param {number=} opt_direction Direction. Default is `0`.
* @return {number|undefined} Constrained resolution.
* @api
* @private
*/
constrainResolution(resolution, opt_delta, opt_direction) {
const delta = opt_delta || 0;
@@ -689,18 +689,6 @@ class View extends BaseObject {
return this.constraints_.resolution(resolution, delta, direction);
}
/**
* Get the constrained rotation of this view.
* @param {number|undefined} rotation Rotation.
* @param {number=} opt_delta Delta. Default is `0`.
* @return {number|undefined} Constrained rotation.
* @api
*/
constrainRotation(rotation, opt_delta) {
const delta = opt_delta || 0;
return this.constraints_.rotation(rotation, delta);
}
/**
* Get the view center.
* @return {import("./coordinate.js").Coordinate|undefined} The center of the view.

View File

@@ -5,7 +5,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 {rotate, rotateWithoutConstraints} from './Interaction.js';
import {rotate} from './Interaction.js';
import PointerInteraction from './Pointer.js';
@@ -81,7 +81,7 @@ class DragRotate extends PointerInteraction {
if (this.lastAngle_ !== undefined) {
const delta = theta - this.lastAngle_;
const rotation = view.getRotation();
rotateWithoutConstraints(view, rotation - delta);
rotate(view, rotation - delta);
}
this.lastAngle_ = theta;
}

View File

@@ -4,7 +4,7 @@
import {disable} from '../rotationconstraint.js';
import ViewHint from '../ViewHint.js';
import {shiftKeyOnly, mouseOnly} from '../events/condition.js';
import {rotate, rotateWithoutConstraints, zoom} from './Interaction.js';
import {rotate, zoom} from './Interaction.js';
import PointerInteraction from './Pointer.js';
@@ -90,7 +90,7 @@ class DragRotateAndZoom extends PointerInteraction {
const view = map.getView();
if (view.getConstraints().rotation !== disable && this.lastAngle_ !== undefined) {
const angleDelta = theta - this.lastAngle_;
rotateWithoutConstraints(view, view.getRotation() - angleDelta);
rotate(view, view.getRotation() - angleDelta);
}
this.lastAngle_ = theta;
if (this.lastMagnitude_ !== undefined) {

View File

@@ -133,18 +133,6 @@ export function pan(view, delta, opt_duration) {
* @param {number=} opt_duration Duration.
*/
export function rotate(view, rotation, opt_anchor, opt_duration) {
rotation = view.constrainRotation(rotation, 0);
rotateWithoutConstraints(view, rotation, opt_anchor, opt_duration);
}
/**
* @param {import("../View.js").default} view View.
* @param {number|undefined} rotation Rotation.
* @param {import("../coordinate.js").Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
export function rotateWithoutConstraints(view, rotation, opt_anchor, opt_duration) {
if (rotation !== undefined) {
const currentRotation = view.getRotation();
const currentCenter = view.getCenter();

View File

@@ -3,7 +3,7 @@
*/
import ViewHint from '../ViewHint.js';
import {FALSE} from '../functions.js';
import {rotate, rotateWithoutConstraints} from './Interaction.js';
import {rotate} from './Interaction.js';
import PointerInteraction, {centroid as centroidFromPointers} from './Pointer.js';
import {disable} from '../rotationconstraint.js';
@@ -120,7 +120,7 @@ class PinchRotate extends PointerInteraction {
if (this.rotating_) {
const rotation = view.getRotation();
map.render();
rotateWithoutConstraints(view, rotation + rotationDelta, this.anchor_);
rotate(view, rotation + rotationDelta, this.anchor_);
}
}