Use ol.math.clamp()
This commit is contained in:
@@ -3,6 +3,19 @@ goog.provide('ol.math');
|
||||
goog.require('goog.asserts');
|
||||
|
||||
|
||||
/**
|
||||
* Takes a number and clamps it to within the provided bounds.
|
||||
* @param {number} value The input number.
|
||||
* @param {number} min The minimum value to return.
|
||||
* @param {number} max The maximum value to return.
|
||||
* @return {number} The input number if it is within bounds, or the nearest
|
||||
* number within the bounds.
|
||||
*/
|
||||
ol.math.clamp = function(value, min, max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} x X.
|
||||
* @return {number} Hyperbolic cosine of x.
|
||||
|
||||
Reference in New Issue
Block a user