title: Jquery detect which block is visible on screen when scroll
body: <p>Hi all I have some questions, if it's not hard please help.</p>
  
  <p>If i have some count of div blocks</p>
  
  <pre><code>&lt;div class="main"&gt;
        &lt;div class="box block1"&gt;&lt;/div&gt;
        &lt;div class="box block2"&gt;&lt;/div&gt;
        &lt;div class="box block3"&gt;&lt;/div&gt;
        &lt;div class="box block4"&gt;&lt;/div&gt;
  &lt;/div&gt; 
  </code></pre>
  
  <p>Ok now when you scroll and block visible on screen I need do something in that block I can do this with jquery every time when I scroll detect scroll top and check it with block offset-top but it bad solution because i need write many "if" to check it and it works when I have fixed count of block but i need that it will work dynamic. I find some plugins but I don't want use plugin. I was some basic easy script that i can change something or add or modify in other web sites</p>
  
  <p>please help if you have some time to do that</p>
  
  <p>it's my html</p>
  
  <p><a href="https://jsfiddle.net/5ppdnbkj/" rel="nofollow">example</a></p>
  
  <p>I do something in my portfolio page but it not dynamic and I write bad code :) </p>
  
  <p>you can see it on menu when you scroll i add active class to menu if visible the block</p>
  
  <p><a href="http://arammkrtchyan.info/" rel="nofollow">portfolio</a></p>