// Function to loop through a SCSS map ($map) and set the map's key values to a
// specific CSS attribute ($target) each time creating a new :nth-of-type rule at
// the key's index.
// For example see "loading" element. (BhLoading.scss)
@mixin enumerate($map, $target, $prop, $val) {
    $keys: map-keys($map);
    @each $item in $keys {
        $idx: index($keys, $item);
        //@debug $idx;
        //@debug $item;
        @if $prop == 'map-val' {
            &:nth-of-type(#{$idx}) {
                #{$target}: map-get($map, $item);
            }
        }

        @if $target == 'transform' {
            &:nth-of-type(#{$idx}) {
                #{$target}: #{'#{$prop}(#{$val * $idx})'};
            }
        }
    }
}

// Animation Delay Function - multiplies $base-speed by key index;
@mixin delay($map, $base-speed) {
    $keys: map-keys($map);
    @each $item in $keys {
        $idx: index($keys, $item);

        &:nth-of-type(#{$idx}) {
            animation-delay: $base-speed * $idx;
        }
    }
}

// FULL Animation Delay Function - multiplies $base-speed by key index;
@mixin animationMapDelay($map, $animation-name, $animation-duration, $animation-timing-function, $delay-base-speed, $animation-direction, $animation-iterate-count, $animation-fill-mode, $animation-play-state) {
    $keys: map-keys($map);
    @each $item in $keys {
        $idx: index($keys, $item);

        &:nth-of-type(#{$idx}) {
            animation: $animation-name $animation-duration $animation-timing-function ($delay-base-speed * $idx) $animation-direction $animation-iterate-count $animation-fill-mode $animation-play-state;
            animation-name: $animation-name;
            animation-duration: $animation-duration;
            animation-timing-function: $animation-timing-function;
            animation-delay: $delay-base-speed * $idx;
            animation-direction: $animation-direction;
            animation-iteration-count: $animation-iterate-count;
            animation-fill-mode: $animation-fill-mode;
            animation-play-state: $animation-play-state;
        }
    }
}
