// Susy Math // ========= // Get all the span results @function span-math( $span, $location, $columns : $columns, $gutters : $gutters, $column-width : $column-width, $isolate : $isolate, $static : $static, $flow : $flow, $gutter-place : $gutter-placement, $is-container : false, $gutter-override : false ) { $float : from($flow); $width : $span; $column : null; $padding-before : null; $padding-after : null; $margin-before : null; $margin-after : null; $static : if($static and $static != fluid, true, false); $isolate : if($isolate and $isolate != float, true, false); // calculations $width: get-span-width($span, $location, $columns, $gutters, $column-width, $static, $gutter-place); // gutter location $gutter-location : get-gutters($columns, $gutters, $column-width, $static, $gutter-place, $gutter-override); @if $gutter-place == inside { @if not $is-container { $padding-before: nth($gutter-location,1); $padding-after: nth($gutter-location,2); } } @else { $margin-before: nth($gutter-location,1); $margin-after: nth($gutter-location,2); } // special margin handling @if $isolate { $margin-before: get-isolation($span, $location, $columns, $gutters, $column-width, $static); $margin-after: -100%; } @else { @if is-last($span, $location, $columns) { $float: to($flow); $margin-after: null; } @else if is-first($location) { $margin-before: null; } } @return $width $float $margin-before $margin-after $padding-before $padding-after $flow; } // Return gutter width @function get-gutter-width( $columns : $columns, $gutters : $gutters, $column-width : $columns-width, $static : $static ) { $context : column-sum($columns, $gutters); $gutter : null; @if $static { @if $column-width { $gutter: $gutters * $column-width; } @else { @warn "Please set a $column-width to use for static output."; } } @else { $gutter: percentage($gutters / $context); } @return $gutter; } @function get-gutters( $columns : $columns, $gutters : $gutters, $column-width : $column-width, $static : $static, $gutter-place : $gutter-placement, $gutter-override : false ) { $static : if($gutter-place == inside and $column-width, true, $static); $gutter : null; $before : null; $after : null; @if $gutter-override { $gutter: $gutter-override; } @else { $gutter: get-gutter-width($columns, $gutters, $column-width, $static); } @if $gutter-place == before { $before: $gutter; } @else if $gutter-place == after { $after: $gutter; } @else if $gutter-place == split or $gutter-place == inside { $gutter: if($gutter-override, $gutter, $gutter / 2); $before: $gutter; $after: $gutter; } @return $before $after; } // Return span width @function get-span-width( $span, $location, $columns : $columns, $gutters : $gutters, $column-width : $column-width, $static : $static, $gutter-place : $gutter-placement, $outer : null ) { $context : null; $span-sum : null; $width : null; @if unitless($span) { @if $gutter-place == inside { $context: column-sum($columns, $gutters, outer); $span-sum: column-sum(get-columns($span, $location, $columns), $gutters, outer); } @else { $context: column-sum($columns, $gutters); $outer: if($outer, $gutters, 0); $span-sum: get-column-span-sum($span, $location, $columns, $gutters) + $outer; } @if $static { $width: $span-sum * $column-width; } @else { $width: percentage($span-sum / $context); } } @else { $width: $span; } @return $width; }