Files
openlayers/src/ol/centerconstraint.js
Tim Schaub ccfacc5ee6 Transformed types
Using the [ts.js codemod](https://gist.github.com/tschaub/1ea498c9d1e5268cf36d212b3949be4e):

    jscodeshift --transform ts.js src
2018-09-05 08:05:29 -06:00

43 lines
942 B
JavaScript

/**
* @module ol/centerconstraint
*/
import {clamp} from './math.js';
/**
* @typedef {function((import("./coordinate.js").Coordinate|undefined)): (import("./coordinate.js").Coordinate|undefined)} Type
*/
/**
* @param {import("./extent.js").Extent} extent Extent.
* @return {Type} The constraint.
*/
export function createExtent(extent) {
return (
/**
* @param {import("./coordinate.js").Coordinate=} center Center.
* @return {import("./coordinate.js").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 {import("./coordinate.js").Coordinate=} center Center.
* @return {import("./coordinate.js").Coordinate|undefined} Center.
*/
export function none(center) {
return center;
}