// Shift indexes from $list of $value // ------------------------------------------------------------------------------- // @documentation http://sassylists.com/documentation/#loop // ------------------------------------------------------------------------------- // @alias `shift-indexes()` // ------------------------------------------------------------------------------- // @example loop(a b c d e) => e, a, b, c, d // @example loop(a b c d e, 2) => d, e, a, b, c // @example loop(a b c d e, -2) => c, d, e, a, b // ------------------------------------------------------------------------------- // @param $list [List] : list // @param $value [Number] : number of position between old and new indexes // ------------------------------------------------------------------------------- // @return [List] @function loop($list, $value: 1) { $result: (); $length: length($list); @for $i from 0 to $length { $result: append($result, nth($list, ($i - $value) % $length + 1)); } @return $result; } // Alias @function shift-indexes($list, $value: 1) { @return loop($list, $value); }