Skip to content

Instantly share code, notes, and snippets.

@VitalyKondratiev
Last active October 10, 2017 12:31
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 VitalyKondratiev/364abc0a125c7585d4e2081042f33e1c to your computer and use it in GitHub Desktop.
Save VitalyKondratiev/364abc0a125c7585d4e2081042f33e1c to your computer and use it in GitHub Desktop.
Плавное "выезжание" блока при скролле страницы
$(document).ready(function (){
$('.for-slidedown').addClass('slidedown-ready')
$(window).on('scroll', function (event) {
$('.for-slidedown.slidedown-ready').each(function () {
if (window.innerHeight + window.pageYOffset >= $(this).offset().top) {
$(this).removeClass('slidedown-ready');
}
});
});
});
/*Навесить класс `for-slidedown` на элементы, к которым следует применить эффект*/
.for-slidedown {
transition: all 1s ease;
transform: translateY(-0px);
opacity: 1;
}
.slidedown-ready {
transform: translateY(-30px);
opacity: 0.2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment