Skip to content

Instantly share code, notes, and snippets.

@LeonBaudouin
Created February 22, 2022 13:58
Show Gist options
  • Save LeonBaudouin/fc4fa457f72b461a3239503cc53521b7 to your computer and use it in GitHub Desktop.
Save LeonBaudouin/fc4fa457f72b461a3239503cc53521b7 to your computer and use it in GitHub Desktop.
@mixin delay($delayOffset, $type, $baseDelay: 0ms, $childNumber: 5) {
@for $i from 1 through $childNumber {
&:nth-child(#{$i}) {
$finalDelay: $baseDelay + $delayOffset * (1 - $i);
@if $type == "both" {
animation-delay: $finalDelay;
transition-delay: $finalDelay;
} @else {
#{$type}-delay: $finalDelay;
}
}
}
}
@mixin animation-delay($delayOffset: 200ms, $baseDelay: 0ms, $childNumber: 5) {
@include delay($delayOffset, "animation", $baseDelay, $childNumber)
}
@mixin transition-delay($delayOffset: 200ms, $baseDelay: 0ms, $childNumber: 5) {
@include delay($delayOffset, "transition", $baseDelay, $childNumber)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment