title: Scrolling element correspond scrolling window
body: <p>I want ask to you "How to create scrolling element correspond with scrolling window."</p>
  
  <p>If window get end of scroll, that element can be scrolling down.
  And if window get start of scroll, that element can be scrolling up.</p>
  
  <p>I was try to make that but didn't solved.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>$(window).on('scroll',function(event) {
          var lengthScrollWindow = $(this)[0].scrollTop;
          if ($(this).scrollTop() == 0) {
              lengthScrollWindow -= 40;
              $('.main_profile').animate({scrollTop: lengthScrollWindow},700);
          }
          else if ($(this).scrollTop() &gt;= $(this)[0].scrollHeight) {
              lengthScrollWindow += 40;
              $('.main_profile').animate({scrollTop: lengthScrollWindow},700);
          }
      });
  </code></pre>
  
  <p>Here is my Fiddle : </p>
  
  <p><a href="https://jsfiddle.net/el_mahbub/23e6ncg9/" rel="nofollow noreferrer">Js Fiddle</a></p>