Skip to content

Instantly share code, notes, and snippets.

@joshuaogle
Created December 8, 2014 16:47
Show Gist options
  • Select an option

  • Save joshuaogle/44b6ac4fbac387cac821 to your computer and use it in GitHub Desktop.

Select an option

Save joshuaogle/44b6ac4fbac387cac821 to your computer and use it in GitHub Desktop.
Animate elements on scroll down
// Needs jQuery and jquery-visible (https://github.com/customd/jquery-visible)
$ ->
if $(".services").length > 0
animate_services_icon = ->
$(".services-list .image").each (i, el) ->
$el = $(el)
if $el.visible(true, true)
$el.addClass("animated")
animate_services_icon()
$(window).scroll (event) -> animate_services_icon()
@include keyframes(reveal) {
0% {
@include transform(translateY(em(30)));
opacity: 0;
}
100% {
@include transform(translateY(0));
opacity: 1;
}
}
...
// On each animated element
&.animated {
@include animation(reveal 1s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment