Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function scrollSidebar() {
  2.             var $sidebar   = $(".sideBar"),
  3.                 $window    = $(window),
  4.                 $mainImage = $(".mainImage"),
  5.                 offset     = $sidebar.offset(),
  6.                 threshold  = $mainImage.height() - $sidebar.height(),
  7.                 topPadding = 15;
  8.                
  9.         if( $mainImage.height() >= 400 ) {
  10.             $window.scroll(function() {
  11.                 if ($window.scrollTop() > threshold) {
  12.                     $sidebar.stop().animate({
  13.                         marginTop: threshold + 60
  14.                     });
  15.                 } else if ($window.scrollTop() > offset.top) {
  16.                     $sidebar.stop().animate({
  17.                         marginTop: $window.scrollTop() - offset.top + topPadding
  18.                     });
  19.                 } else {
  20.                     $sidebar.stop().animate({
  21.                         marginTop: '40px'
  22.                     });
  23.                 }
  24.             });
  25.            
  26.             $('a.zoomedImage').click(function() {
  27.                 setTimeout(scrollSidebar, 1000);
  28.             });
  29.         }
  30.     }
  31.    
  32.     setTimeout(scrollSidebar, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement