Refactor constraints static methods to module functions

This commit is contained in:
Björn Harrtell
2018-02-14 18:21:56 +01:00
parent 18fa8ddc58
commit 208ca098f2
9 changed files with 46 additions and 54 deletions

View File

@@ -0,0 +1,37 @@
/**
* @module ol/centerconstraint
*/
import {clamp} from './math.js';
/**
* @param {ol.Extent} extent Extent.
* @return {ol.CenterConstraintType} The constraint.
*/
export function createExtent(extent) {
return (
/**
* @param {ol.Coordinate|undefined} center Center.
* @return {ol.Coordinate|undefined} Center.
*/
function(center) {
if (center) {
return [
clamp(center[0], extent[0], extent[2]),
clamp(center[1], extent[1], extent[3])
];
} else {
return undefined;
}
}
);
}
/**
* @param {ol.Coordinate|undefined} center Center.
* @return {ol.Coordinate|undefined} Center.
*/
export function none(center) {
return center;
}