MCPcopy
hub / github.com/MrNothing/AI-Blocks / clamp

Function clamp

Sources/src/libs/jquery-ui.js:1482–1507  ·  view source on GitHub ↗
( value, prop, allowEmpty )

Source from the content-addressed store, hash-verified

1480} );
1481
1482function clamp( value, prop, allowEmpty ) {
1483 var type = propTypes[ prop.type ] || {};
1484
1485 if ( value == null ) {
1486 return ( allowEmpty || !prop.def ) ? null : prop.def;
1487 }
1488
1489 // ~~ is an short way of doing floor for positive numbers
1490 value = type.floor ? ~~value : parseFloat( value );
1491
1492 // IE will pass in empty strings as value for alpha,
1493 // which will hit this case
1494 if ( isNaN( value ) ) {
1495 return prop.def;
1496 }
1497
1498 if ( type.mod ) {
1499
1500 // We add mod before modding to make sure that negatives values
1501 // get converted properly: -10 -> 350
1502 return ( value + type.mod ) % type.mod;
1503 }
1504
1505 // For now all property types without mod have min and max
1506 return 0 > value ? 0 : type.max < value ? type.max : value;
1507}
1508
1509function stringParse( string ) {
1510 var inst = color(),

Callers 1

jquery-ui.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected