Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2.  
  3. // Add class .fixed when .site-header hits top of viewport
  4.  
  5. var distance = $('.site-header').offset().top,
  6. $window = $(window);
  7.  
  8. $window.scroll(function() {
  9. if ( $window.scrollTop() >= distance ) {
  10. $(".site-header").addClass("fixed");
  11. }
  12. if ( $window.scrollTop() < distance ) {
  13. $(".site-header").removeClass("fixed");
  14. }
  15. });
  16.  
  17. // Add class .scrolled on scroll to control show/hide of back-top button
  18.  
  19. $(window).scroll(function() {
  20. var scroll = $(window).scrollTop();
  21.  
  22. if (scroll >= 200) {
  23. $("body").addClass("scrolled");
  24. }
  25. if (scroll <= 200) {
  26. $("body").removeClass("scrolled");
  27. }
  28. });
  29.  
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement