bfcce9293b4e04e22cd77cb21b2ff167f0183909
[roojs1] / docs / src / Number.js.html
1 <html><head><title>Number.js</title><link rel="stylesheet" type="text/css" href="../../css/highlight-js.css"/></head><body class="highlightpage"><code class="jsdoc-pretty"><span class="jsdoc-comment">/*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * &lt;script type=&quot;text/javascript&quot;&gt;
10  */
11
12  /**
13  * @class Number
14  */
15 </span><span class="jsdoc-var">Roo.applyIf</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Number.prototype</span><span class="jsdoc-syntax">, {
16     </span><span class="jsdoc-comment">/**
17      * Checks whether or not the current number is within a desired range.  If the number is already within the
18      * range it is returned, otherwise the min or max value is returned depending on which side of the range is
19      * exceeded.  Note that this method returns the constrained value but does not change the current number.
20      * @param {Number} min The minimum number in the range
21      * @param {Number} max The maximum number in the range
22      * @return {Number} The constrained value if outside the range, otherwise the current value
23      */
24     </span><span class="jsdoc-var">constrain </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">min</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">max</span><span class="jsdoc-syntax">){
25         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">Math.min</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Math.max</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">min</span><span class="jsdoc-syntax">), </span><span class="jsdoc-var">max</span><span class="jsdoc-syntax">);
26     }
27 });</span></code></body></html>