Posted By

onefastsnail on 05/24/12


Tagged


Versions (?)

fixed scroll


 / Published in: Other
 

  1. var $comment = $('.def_index'),
  2. top = $comment.offset().top - parseFloat($comment.css('marginTop').replace(/auto/, 0)),
  3. $window = $(window);
  4.  
  5. $window.scroll(function (event) {
  6. // what the y position of the scroll is
  7. var y = $window.scrollTop();
  8.  
  9. // whether that's below the form
  10. if (y >= top) {
  11. // if so, ad the fixed class
  12. $comment.addClass('fixed');
  13. } else {
  14. // otherwise remove it
  15. $comment.removeClass('fixed');
  16. }
  17. });

Report this snippet  

You need to login to post a comment.