       if nav.size() == 0
         @_log "No more pages to load"
       else
-        windowBottom = $(window).scrollTop() + $(window).height()
+        windowBottom = @$container.scrollTop() + @$container.height()
         distance = nav.offset().top - windowBottom
         
         if @options.state.paused

      @options = $.extend({}, @defaults, options)
      @$container = $(container)
      @$table = $(container).find('table')
      
      @init()
      
    # Setup and bind to related events

      scrollTimeout = null
      scrollHandler = (=> @check())
      
      @$container.scroll ->
        if scrollTimeout
          clearTimeout(scrollTimeout)
          scrollTimeout = null
