Last active
December 23, 2015 04:39
-
-
Save jakob-e/6581310 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Strip units (from unit conversion) | |
@function number($val){ | |
@if($val==null){ @return null;} | |
@return $val/($val*0+1); | |
} | |
// ====================== | |
// Inbuild | |
// ====================== | |
// floor | |
// ceil | |
// abs | |
// min | |
// max | |
// Returns the closest number within the range of min and max | |
// E.g. clamp(-20, 10, 30) will return 10 | |
@function clamp($val, $min, $max) { | |
$val:number($val); $min:number($min); $max:number($max); | |
@return if($val > $max, $max, | |
if($val < $min, $min, | |
$val)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment