Created
August 4, 2014 12:46
-
-
Save dmitry-ilyashevich/866e8b7f25506aaf8fa6 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.0.rc.1) | |
// Compass (v1.0.0.alpha.20) | |
// ---- | |
/** | |
* Clamp `$value` between `$min` and `$max`. | |
* | |
* @access public | |
* | |
* @author Stan Angeloff | |
* | |
* @link https://github.com/sass/sass/pull/402 Clamp function on Sass's repo | |
* | |
* @param {Number} $value - value to clamp | |
* @param {Number} $min (0) - minimal value | |
* @param {Number} $max (1) - maximum value | |
* | |
* @throws All arguments must be numbers for `clamp`. | |
* | |
* @return {Number} - clamped number | |
*/ | |
@function clamp($value, $min: 0, $max: 1) { | |
@if type-of($value) != "number" or type-of($min) != "number" or type-of($max) != "number" { | |
@error "All arguments must be numbers for `clamp`."; | |
} | |
@return if($value > $max, $max, if($value < $min, $min, $value)); | |
} | |
test { | |
clamp: clamp(42); | |
clamp: clamp("string"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All arguments must be numbers for `clamp`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment