title: Toggle class when object visible in the viewport
body: <p>I need a script which toggle a class when another class or section is visible in the viewport (during scrolling).</p>
  
  <p>Here I have an script which works for precised distance from top, but can somebody help me to modify it for my needs?</p>
  
  <pre><code>$(window).scroll(function(){
        if ($(this).scrollTop() &gt; 50) {
            $('#viewport').addClass('turn_on');
        } else {
            $('#viewport').removeClass('turn_on');
        }
    });
  </code></pre>