-<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-Number'>/**
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-Number'>/**
</span> * @class Ext.Number
*
* A collection of useful static methods to deal with numbers
Ext.Number = {
<span id='Ext-Number-method-constrain'> /**
-</span> * Checks whether or not the current number is within a desired range. If the number is already within the
+</span> * Checks whether or not the passed number is within a desired range. If the number is already within the
* range it is returned, otherwise the min or max value is returned depending on which side of the range is
* exceeded. Note that this method returns the constrained value but does not change the current number.
* @param {Number} number The number to check
return number;
},
+<span id='Ext-Number-method-snap'> /**
+</span> * Snaps the passed number between stopping points based upon a passed increment value.
+ * @param {Number} value The unsnapped value.
+ * @param {Number} increment The increment by which the value must move.
+ * @param {Number} minValue The minimum value to which the returned value must be constrained. Overrides the increment..
+ * @param {Number} maxValue The maximum value to which the returned value must be constrained. Overrides the increment..
+ * @return {Number} The value of the nearest snap target.
+ */
+ snap : function(value, increment, minValue, maxValue) {
+ var newValue = value,
+ m;
+
+ if (!(increment && value)) {
+ return value;
+ }
+ m = value % increment;
+ if (m !== 0) {
+ newValue -= m;
+ if (m * 2 >= increment) {
+ newValue += increment;
+ } else if (m * 2 < -increment) {
+ newValue -= increment;
+ }
+ }
+ return Ext.Number.constrain(newValue, minValue, maxValue);
+ },
+
<span id='Ext-Number-method-toFixed'> /**
</span> * Formats a number using fixed-point notation
* @param {Number} value The number to format
*/
Ext.num = function() {
return Ext.Number.from.apply(this, arguments);
-};</pre></pre></body></html>
\ No newline at end of file
+};</pre>
+</body>
+</html>