Created
September 24, 2014 17:37
-
-
Save KittyGiraudel/8d24cb970d1b5f90841a to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
| // ---- | |
| // Sass (v3.4.4) | |
| // Compass (v1.0.1) | |
| // ---- | |
| // Clamp | |
| // Old version | |
| // Works fine but is barely readable | |
| // And quite long | |
| @function old-clamp($value, $min, $max) { | |
| @return if($value > $max, $max, if($value < $min, $min, $value)); | |
| } | |
| // Clamp | |
| // New version | |
| // Works fine and is fully readable | |
| @function new-clamp($value, $min, $max) { | |
| @return min($max, max($min, $value)); | |
| } | |
| $min: 1; | |
| $max: 10; | |
| test-old { | |
| test: old-clamp(0, $min, $max); | |
| test: old-clamp(1, $min, $max); | |
| test: old-clamp(5, $min, $max); | |
| test: old-clamp(10, $min, $max); | |
| test: old-clamp(11, $min, $max); | |
| } | |
| test-new { | |
| test: new-clamp(0, $min, $max); | |
| test: new-clamp(1, $min, $max); | |
| test: new-clamp(5, $min, $max); | |
| test: new-clamp(10, $min, $max); | |
| test: new-clamp(11, $min, $max); | |
| } |
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
| test-old { | |
| test: 1; | |
| test: 1; | |
| test: 5; | |
| test: 10; | |
| test: 10; | |
| } | |
| test-new { | |
| test: 1; | |
| test: 1; | |
| test: 5; | |
| test: 10; | |
| test: 10; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment