 			# find first visible page
 			visible = $scope.pages.some (page, i) ->
 				[topPageIdx, topPage] = [i, page] if page.visible
-			if 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.elemTop
-			bottom = topPage.elemBottom
-			viewportTop = 0
-			viewportHeight = $element.height()
-			topVisible = (top >= viewportTop && top < viewportTop + viewportHeight)
+			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

				scope.$on 'layout-ready', () ->
					# console.log 'GOT LAYOUT READY EVENT'
					# console.log 'calling refresh'
					updateContainer()
					spinner.add(element)
					layoutReady.resolve 'layout is ready'
					scope.parentSize = [

				layoutReady.promise.then () ->
					# console.log 'layoutReady was resolved'

				renderVisiblePages = () ->
					visiblePages = getVisiblePages()
					pages = getExtraPages visiblePages
					scope.document.renderPages(pages)

				getVisiblePages = () ->
					top = element.offset().top
