MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / clamp

Function clamp

Three.js/js/jquery-ui.js:4902–4926  ·  view source on GitHub ↗
( value, prop, allowEmpty )

Source from the content-addressed store, hash-verified

4900});
4901
4902function clamp( value, prop, allowEmpty ) {
4903 var type = propTypes[ prop.type ] || {};
4904
4905 if ( value == null ) {
4906 return (allowEmpty || !prop.def) ? null : prop.def;
4907 }
4908
4909 // ~~ is an short way of doing floor for positive numbers
4910 value = type.floor ? ~~value : parseFloat( value );
4911
4912 // IE will pass in empty strings as value for alpha,
4913 // which will hit this case
4914 if ( isNaN( value ) ) {
4915 return prop.def;
4916 }
4917
4918 if ( type.mod ) {
4919 // we add mod before modding to make sure that negatives values
4920 // get converted properly: -10 -> 350
4921 return (value + type.mod) % type.mod;
4922 }
4923
4924 // for now all property types without mod have min and max
4925 return 0 > value ? 0 : type.max < value ? type.max : value;
4926}
4927
4928function stringParse( string ) {
4929 var inst = color(),

Callers 1

jquery-ui.jsFile · 0.70

Calls 1

isNaNFunction · 0.85

Tested by

no test coverage detected