-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`@function direction-opposite($dir)`: Return the opposite direction of $dir, between "top", "right", "bottom" and "left".
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Foundation for Sites by ZURB | ||
// foundation.zurb.com | ||
// Licensed under MIT Open Source | ||
|
||
//// | ||
/// @group functions | ||
//// | ||
|
||
/// Return the opposite direction of $dir | ||
/// | ||
/// @param {Keyword} $dir - Used direction between "top", "right", "bottom" and "left". | ||
/// @return {Keyword} Opposite direction of $dir | ||
@function direction-opposite( | ||
$dir | ||
) { | ||
$dirs: (top, right, bottom, left); | ||
$place: index($dirs, $dir); | ||
|
||
@if $place == null { | ||
@error 'direction-opposite: Invalid $dir parameter, expected a value from "' + $dirs + '", found "' + $dir + '".'; | ||
@return null; | ||
} | ||
|
||
// Calcul the opposite place in a circle, with a starting index of 1 | ||
$length: length($dirs); | ||
$demi: $length / 2; | ||
$opposite-place: (($place + $demi - 1) % $length) + 1; | ||
|
||
@return nth($dirs, $opposite-place); | ||
} | ||
|
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