Last active
March 30, 2017 10:45
-
-
Save chy4egg/94af3578df799dd00f1acf3b47fed80e to your computer and use it in GitHub Desktop.
Action on scroll script (jQuery)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery addClass on scroll | |
var section1 = $('.css-class').offset().top; | |
var section2 = $('.css-class-2').offset().top; | |
$(window).scroll(function(){ | |
//section-1 | |
if( $(window).scrollTop() > section1 ) { | |
$('.css-class').addClass('active'); //добавить класс, когда проскроллил элемент. | |
} else { | |
$('.css-class').removeClass('active'); //убрать класс, когда проскроллил обратно. | |
} | |
//section-2 | |
if( $(window).scrollTop() > section2 ) { | |
$('.advantages__fixed-nav-1').addClass('advantages__fixed-nav-2'); | |
} else { | |
$('.advantages__fixed-nav-1').removeClass('advantages__fixed-nav-2'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment