title: Element flicking on and off while scrolling
body: <p>I've been trying to use jQuery to add a class to a div when the user scrolls past it, and then removed again when they scroll back to the div's original position. It is being used for a forum so that when the user scrolls past the breadcrumbs they stick to the top of the page. This is the code I'm currently using:</p>
  
  <pre><code>$.noConflict();
  jQuery(document).ready(function($){
       $(window).scroll( function() {
          if ($(window).scrollTop() &gt; $('#secondary_navigation').offset().top)
              $('#secondary_navigation').addClass('floating');
          else
              $('#secondary_navigation').removeClass('floating');
      } );
  });
  </code></pre>
  
  <p>It works...almost; however when the div is stuck to the top of the page it flickers on and off. When looking at the live code the class is constantly been added and removed, resulting in a horrible scrolling experience.</p>
  
  <p>Does anybody have any idea why this is happening?</p>