title: Scroll Event inside Facebook Canvas Applications
body: <p>I'm looking to use a LazyLoad technique for images and infinite scroll to load new content into my page. Both these things make use of the <code>$(window).scrollTop()</code> function that inside a Facebook canvas application doesn't work. I know i can use <code>FB.Canvas.getPageInfo()</code> to get the current scrollTop value however I'm encountering some performance issues with this, my code is as follows:</p>
  
  <pre><code>var oldScroll = 0;       // current scroll 
  var newScroll = null;    // new scroll (fetched from FB.Canvas)
  
  // Override the normal function to work within fb
  // !!This seems to kill the browser
  $.fn.scrollTop = function() {
      return FB.Canvas.getPageInfo().scrollTop;  
  };
  
  // poll to check for any changes in scroll
  setInterval(function() {
      newScroll = FB.Canvas.getPageInfo().scrollTop; 
  
      if(oldScroll != newScroll) {     // have we scrolled at all?
          oldScroll = newScroll;
          $(window).trigger($.Event('scroll'));   // fire a scroll event to keep the rest of the application that is listening
      }
  }, 1000);
  </code></pre>
  
  <p>It appears to be fine if i don't override the scrollTop function but once I do my browser soon crashes. </p>
  
  <p>Am i going about this completely wrong? Has someone already created a way to do this inside FB canvas? Cheers.</p>