Skip to content

Instantly share code, notes, and snippets.

@gregogalante
Last active February 12, 2016 13:06
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 gregogalante/21196b4aa786f50a5c9c to your computer and use it in GitHub Desktop.
Save gregogalante/21196b4aa786f50a5c9c to your computer and use it in GitHub Desktop.
Effetto di comparsa elementi durante lo scrolling. Funzione dipendente dal plugin jquery-visible (https://github.com/customd/jquery-visible).
// Funzione da richiamare nel document.ready
var scrollEffectsInit = function() {
if($(window).width() > 1024) {
$('.animate').css('opacity', '0');
$('.animate-left').css('left', '-100px');
$('.animate-right').css('right', '-100px');
$('.animate-top').css('top', '-100px');
$('.animate-bottom').css('bottom', '-100px');
}
}
// Funzione da richiamare nel window.scroll
var scrollEffectsExec = function() {
if($(window).width() > 1024) {
$('.animate').each(function() {
if($(this).visible(true)) {
$(this).css('opacity', '1');
if($(this).hasClass('animate-left')) {
$(this).css('left', '0');
} else if($(this).hasClass('animate-right')) {
$(this).css('right', '0');
} else if($(this).hasClass('animate-top')) {
$(this).css('top', '0');
} else if($(this).hasClass('animate-bottom')) {
$(this).css('bottom', '0');
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment