Skip to content

Instantly share code, notes, and snippets.

@coolniikou
Created November 21, 2012 15:53
Show Gist options
  • Save coolniikou/4125600 to your computer and use it in GitHub Desktop.
Save coolniikou/4125600 to your computer and use it in GitHub Desktop.
jQuery Scroll Setting
jQuery Scroll Setting
$(function () {
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$(".navbar.navbar-fixed-top").addClass("scroll");
} else {
$(".navbar.navbar-fixed-top").removeClass("scroll");
}
if ($(this).scrollTop() > 300) {
$('.scrolltop').fadeIn();
} else {
$('.scrolltop').fadeOut();
}
});
$('.scrolltop').click(function(){
$("html, body").animate({ scrollTop: 0 }, 700);
return false;
});
$('.scroller').click(function(){
var section = $($(this).data("section"));
var top = section.offset().top;
$("html, body").animate({ scrollTop: top }, 700);
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment