Skip to content

Instantly share code, notes, and snippets.

@bekharsky
Last active September 29, 2016 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bekharsky/6bf3f98ffc5643706127e0a4c4727d5b to your computer and use it in GitHub Desktop.
Save bekharsky/6bf3f98ffc5643706127e0a4c4727d5b to your computer and use it in GitHub Desktop.
Position icons in the staggered order
@step: @icon-size + 12 / 1366 * 100vw;
@t: @icon-size * 0.35;
@l: -@icon-size;
@d: 5ms;
@from: 0;
@to: 17;
@break: 6;
.loop(@index) when(@index =< @to) {
@i: @index + 1;
& when (not(mod(@i, 2) = 0)) {
&:nth-child(@{i}) {
top: @step * (@i - 1) / 2;
left: 0;
transition-delay: (@to - @index) * @d;
}
}
& when (mod(@i, 2) = 0) {
&:nth-child(@{i}) {
top: @t + @step * (@i - 2) / 2;
left: @l;
transition-delay: (@to - @index) * @d;
}
}
& when (@index <= @break) {
@c: @break - @index;
&:nth-child(@{i}):nth-last-child(@{c}) {
top: @step * @index;
left: 0;
transition-delay: (@break - @i) * @d;
}
}
.loop(@index + 1);
}
.full-page--icons > a {
.loop(@from);
&.moving {
top: 0 !important;
left: 0 !important;
}
}
@bekharsky
Copy link
Author

This is also a fairly good example of LESS loops and "if" conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment