Rename _ol_RotationConstraint_ to RotationConstraint
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @module ol/RotationConstraint
|
||||
*/
|
||||
import {toRadians} from './math.js';
|
||||
var _ol_RotationConstraint_ = {};
|
||||
var RotationConstraint = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,7 @@ var _ol_RotationConstraint_ = {};
|
||||
* @param {number} delta Delta.
|
||||
* @return {number|undefined} Rotation.
|
||||
*/
|
||||
_ol_RotationConstraint_.disable = function(rotation, delta) {
|
||||
RotationConstraint.disable = function(rotation, delta) {
|
||||
if (rotation !== undefined) {
|
||||
return 0;
|
||||
} else {
|
||||
@@ -24,7 +24,7 @@ _ol_RotationConstraint_.disable = function(rotation, delta) {
|
||||
* @param {number} delta Delta.
|
||||
* @return {number|undefined} Rotation.
|
||||
*/
|
||||
_ol_RotationConstraint_.none = function(rotation, delta) {
|
||||
RotationConstraint.none = function(rotation, delta) {
|
||||
if (rotation !== undefined) {
|
||||
return rotation + delta;
|
||||
} else {
|
||||
@@ -37,7 +37,7 @@ _ol_RotationConstraint_.none = function(rotation, delta) {
|
||||
* @param {number} n N.
|
||||
* @return {ol.RotationConstraintType} Rotation constraint.
|
||||
*/
|
||||
_ol_RotationConstraint_.createSnapToN = function(n) {
|
||||
RotationConstraint.createSnapToN = function(n) {
|
||||
var theta = 2 * Math.PI / n;
|
||||
return (
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ _ol_RotationConstraint_.createSnapToN = function(n) {
|
||||
* @param {number=} opt_tolerance Tolerance.
|
||||
* @return {ol.RotationConstraintType} Rotation constraint.
|
||||
*/
|
||||
_ol_RotationConstraint_.createSnapToZero = function(opt_tolerance) {
|
||||
RotationConstraint.createSnapToZero = function(opt_tolerance) {
|
||||
var tolerance = opt_tolerance || toRadians(5);
|
||||
return (
|
||||
/**
|
||||
@@ -80,4 +80,4 @@ _ol_RotationConstraint_.createSnapToZero = function(opt_tolerance) {
|
||||
}
|
||||
});
|
||||
};
|
||||
export default _ol_RotationConstraint_;
|
||||
export default RotationConstraint;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {inherits, getUid, nullFunction} from './index.js';
|
||||
import CenterConstraint from './CenterConstraint.js';
|
||||
import _ol_Object_ from './Object.js';
|
||||
import ResolutionConstraint from './ResolutionConstraint.js';
|
||||
import _ol_RotationConstraint_ from './RotationConstraint.js';
|
||||
import RotationConstraint from './RotationConstraint.js';
|
||||
import _ol_ViewHint_ from './ViewHint.js';
|
||||
import _ol_ViewProperty_ from './ViewProperty.js';
|
||||
import {linearFindNearest} from './array.js';
|
||||
@@ -1189,16 +1189,16 @@ _ol_View_.createRotationConstraint_ = function(options) {
|
||||
if (enableRotation) {
|
||||
var constrainRotation = options.constrainRotation;
|
||||
if (constrainRotation === undefined || constrainRotation === true) {
|
||||
return _ol_RotationConstraint_.createSnapToZero();
|
||||
return RotationConstraint.createSnapToZero();
|
||||
} else if (constrainRotation === false) {
|
||||
return _ol_RotationConstraint_.none;
|
||||
return RotationConstraint.none;
|
||||
} else if (typeof constrainRotation === 'number') {
|
||||
return _ol_RotationConstraint_.createSnapToN(constrainRotation);
|
||||
return RotationConstraint.createSnapToN(constrainRotation);
|
||||
} else {
|
||||
return _ol_RotationConstraint_.none;
|
||||
return RotationConstraint.none;
|
||||
}
|
||||
} else {
|
||||
return _ol_RotationConstraint_.disable;
|
||||
return RotationConstraint.disable;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/interaction/DragRotate
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_RotationConstraint_ from '../RotationConstraint.js';
|
||||
import RotationConstraint from '../RotationConstraint.js';
|
||||
import _ol_ViewHint_ from '../ViewHint.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
@@ -67,7 +67,7 @@ DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
if (view.getConstraints().rotation === _ol_RotationConstraint_.disable) {
|
||||
if (view.getConstraints().rotation === RotationConstraint.disable) {
|
||||
return;
|
||||
}
|
||||
var size = map.getSize();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/interaction/DragRotateAndZoom
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_RotationConstraint_ from '../RotationConstraint.js';
|
||||
import RotationConstraint from '../RotationConstraint.js';
|
||||
import _ol_ViewHint_ from '../ViewHint.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
@@ -87,7 +87,7 @@ DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
var theta = Math.atan2(deltaY, deltaX);
|
||||
var magnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
var view = map.getView();
|
||||
if (view.getConstraints().rotation !== _ol_RotationConstraint_.disable && this.lastAngle_ !== undefined) {
|
||||
if (view.getConstraints().rotation !== RotationConstraint.disable && this.lastAngle_ !== undefined) {
|
||||
var angleDelta = theta - this.lastAngle_;
|
||||
Interaction.rotateWithoutConstraints(
|
||||
view, view.getRotation() - angleDelta);
|
||||
|
||||
@@ -6,7 +6,7 @@ import _ol_ViewHint_ from '../ViewHint.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
|
||||
import _ol_RotationConstraint_ from '../RotationConstraint.js';
|
||||
import RotationConstraint from '../RotationConstraint.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -98,7 +98,7 @@ _ol_interaction_PinchRotate_.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
if (view.getConstraints().rotation === _ol_RotationConstraint_.disable) {
|
||||
if (view.getConstraints().rotation === RotationConstraint.disable) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_RotationConstraint_ from '../../../src/ol/RotationConstraint.js';
|
||||
import RotationConstraint from '../../../src/ol/RotationConstraint.js';
|
||||
|
||||
|
||||
describe('ol.RotationConstraint', function() {
|
||||
@@ -6,7 +6,7 @@ describe('ol.RotationConstraint', function() {
|
||||
describe('SnapToZero', function() {
|
||||
|
||||
it('returns expected rotation value', function() {
|
||||
var rotationConstraint = _ol_RotationConstraint_.createSnapToZero(0.3);
|
||||
var rotationConstraint = RotationConstraint.createSnapToZero(0.3);
|
||||
|
||||
expect(rotationConstraint(0.1, 0)).to.eql(0);
|
||||
expect(rotationConstraint(0.2, 0)).to.eql(0);
|
||||
|
||||
Reference in New Issue
Block a user