 				layoutReady.promise.then () ->
 					# console.log 'layoutReady was resolved'
 
-				# TODO can we combine this with scope.parentSize, need to finalize boxes
-				updateContainer = () ->
-					scope.containerSize = [
-						element.innerWidth()
-						element.innerHeight()
-						element.offset().top
-					]
+				renderVisiblePages = () ->
+					visiblePages = getVisiblePages()
+					pages = getExtraPages visiblePages
+					scope.document.renderPages(pages)
 
 				getVisiblePages = () ->
 					top = element.offset().top


				element.on 'scroll', () ->
					#console.log 'scroll event', element.scrollTop(), 'adjusting?', scope.adjustingScroll
					scope.scrollPosition = element.scrollTop()
					if scope.adjustingScroll
						updateContainer()
						scope.$apply()
						scope.adjustingScroll = false
						return
					scope.scrolled = true
					if scope.scrollHandlerTimeout
						$timeout.cancel(scope.scrollHandlerTimeout)
					scope.scrollHandlerTimeout = $timeout scrollHandler, 25

				scrollHandler = () ->
					visiblePages = getVisiblePages()
					pages = getExtraPages visiblePages
					scope.document.renderPages(pages)
					scope.$apply()
					newPosition = ctrl.getPdfPosition()
					if newPosition?

			# find first visible page
			visible = $scope.pages.some (page, i) ->
				[topPageIdx, topPage] = [i, page] if page.visible
			if visible && topPage.element?
				# console.log 'found it', topPageIdx
			else
				# console.log 'CANNOT FIND TOP PAGE'
				return

			# console.log 'top page is', topPage.pageNum, topPage.elemTop, topPage.elemBottom, topPage
			top = topPage.element.offset().top
			bottom = top + topPage.element.innerHeight()
			viewportTop = $element.offset().top
			viewportBottom = viewportTop + $element.height()
			topVisible = (top >= viewportTop && top < viewportBottom)
			someContentVisible = (top < viewportTop && bottom > viewportTop)
			# console.log 'in PdfListView', top, topVisible, someContentVisible, viewportTop
			if topVisible
