# all files / ol/ centerconstraint.js

54.55% Statements 6/11
0% Branches 0/2
0% Functions 0/3
54.55% Lines 6/11

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    431×
    1×

    1×

    1×

    1×

    1×

     goog.provide('ol.CenterConstraint');
    goog.provide('ol.CenterConstraintType');

    goog.require('ol.math');

    /**
     * @typedef {function((ol.Coordinate|undefined)): (ol.Coordinate|undefined)}
     */
    ol.CenterConstraintType;

    /**
     * @param {ol.Extent} extent Extent.
     * @return {ol.CenterConstraintType}
     */
    ol.CenterConstraint.createExtent = function(extent) {
      return (
          /**
           * @param {ol.Coordinate|undefined} center Center.
           * @return {ol.Coordinate|undefined} Center.
           */
          function(center) {
            if (center) {
              return [
                ol.math.clamp(center[0], extent[0], extent[2]),
                ol.math.clamp(center[1], extent[1], extent[3])
              ];
            } else {
              return undefined;
            }
          });
    };

    /**
     * @param {ol.Coordinate|undefined} center Center.
     * @return {ol.Coordinate|undefined} Center.
     */
    ol.CenterConstraint.none = function(center) {
      return center;
    };