avoid exception in pdf viewer when no visible pages

This commit is contained in:
Brian Gough 2016-07-13 14:14:51 +01:00
parent d8c11a0824
commit d53fa5de47

View file

@ -275,20 +275,21 @@ define [
getExtraPages = (visiblePages) -> getExtraPages = (visiblePages) ->
extra = [] extra = []
firstVisiblePage = visiblePages[0].pageNum if visiblePages.length > 0
firstVisiblePageIdx = firstVisiblePage - 1 firstVisiblePage = visiblePages[0].pageNum
len = visiblePages.length firstVisiblePageIdx = firstVisiblePage - 1
lastVisiblePage = visiblePages[len-1].pageNum len = visiblePages.length
lastVisiblePageIdx = lastVisiblePage - 1 lastVisiblePage = visiblePages[len-1].pageNum
# first page after lastVisiblePageIdx = lastVisiblePage - 1
if lastVisiblePageIdx + 1 < scope.pages.length # first page after
extra.push scope.pages[lastVisiblePageIdx + 1] if lastVisiblePageIdx + 1 < scope.pages.length
# page before extra.push scope.pages[lastVisiblePageIdx + 1]
if firstVisiblePageIdx > 0 # page before
extra.push scope.pages[firstVisiblePageIdx - 1] if firstVisiblePageIdx > 0
# second page after extra.push scope.pages[firstVisiblePageIdx - 1]
if lastVisiblePageIdx + 2 < scope.pages.length # second page after
extra.push scope.pages[lastVisiblePageIdx + 2] if lastVisiblePageIdx + 2 < scope.pages.length
extra.push scope.pages[lastVisiblePageIdx + 2]
return visiblePages.concat extra return visiblePages.concat extra
rescaleTimer = null rescaleTimer = null