Skip to content

Instantly share code, notes, and snippets.

@kimniche
Created August 22, 2018 17:34
Show Gist options
  • Save kimniche/de3ddf4f30d4aa1076cfbbd72204ddda to your computer and use it in GitHub Desktop.
Save kimniche/de3ddf4f30d4aa1076cfbbd72204ddda to your computer and use it in GitHub Desktop.

Less

@max-nth-child: 7;

.make-animation-delay (@index, @delay) when (@index < @max-nth-child) {
  .mega-menu__item:nth-child(@{index}) {
    animation-delay: unit(@delay, s);
  }
  
  .make-animation-delay(@index + 1, @delay + 0.06);
}

.make-animation-delay(0, 0.12);

Generated CSS

.mega-menu__item:nth-child(0) {
  animation-delay: 0.12s;
}
.mega-menu__item:nth-child(1) {
  animation-delay: 0.18s;
}
.mega-menu__item:nth-child(2) {
  animation-delay: 0.24s;
}
.mega-menu__item:nth-child(3) {
  animation-delay: 0.3s;
}
.mega-menu__item:nth-child(4) {
  animation-delay: 0.36s;
}
.mega-menu__item:nth-child(5) {
  animation-delay: 0.42s;
}
.mega-menu__item:nth-child(6) {
  animation-delay: 0.48s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment