mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
handle different page size in pdf viewer
This commit is contained in:
parent
c9e019b4a7
commit
f18f862be2
3 changed files with 22 additions and 2 deletions
|
@ -38,6 +38,7 @@ define [
|
|||
text: textElement
|
||||
annotations: annotationsElement
|
||||
highlights: highlightsElement
|
||||
container: element
|
||||
}
|
||||
|
||||
if !scope.page.sized
|
||||
|
|
|
@ -25,6 +25,7 @@ define [
|
|||
pdfDocument.getDownloadInfo().then () =>
|
||||
@options.loadedCallback()
|
||||
@errorCallback = @options.errorCallback
|
||||
@pageSizeChangeCallback = @options.pageSizeChangeCallback
|
||||
@pdfjs.catch (exception) =>
|
||||
# console.log 'ERROR in get document', exception
|
||||
@errorCallback(exception)
|
||||
|
@ -216,8 +217,14 @@ define [
|
|||
canvas.height(newHeight + 'px')
|
||||
canvas.width(newWidth + 'px')
|
||||
|
||||
element.canvas.height(newHeight)
|
||||
element.canvas.width(newWidth)
|
||||
oldHeight = element.canvas.height()
|
||||
oldWidth = element.canvas.width()
|
||||
if newHeight != oldHeight or newWidth != oldWidth
|
||||
element.canvas.height(newHeight + 'px')
|
||||
element.canvas.width(newWidth + 'px')
|
||||
element.container.height(newHeight + 'px')
|
||||
element.container.width(newWidth + 'px')
|
||||
@pageSizeChangeCallback?(pagenum, newHeight - oldHeight)
|
||||
|
||||
if pixelRatio != 1
|
||||
ctx.scale(pixelRatio, pixelRatio)
|
||||
|
|
|
@ -40,6 +40,8 @@ define [
|
|||
errorCallback: (error) ->
|
||||
Raven.captureMessage?('pdfng error ' + error)
|
||||
$scope.$emit 'pdf:error', error
|
||||
pageSizeChangeCallback: (pageNum, deltaH) ->
|
||||
$scope.$broadcast 'pdf:page:size-change', pageNum, deltaH
|
||||
})
|
||||
|
||||
# we will have all the main information needed to start display
|
||||
|
@ -336,6 +338,16 @@ define [
|
|||
# trigger a redraw
|
||||
scope.scale = angular.copy (scope.scale)
|
||||
|
||||
scope.$on 'pdf:page:size-change', (event, pageNum, delta) ->
|
||||
#console.log 'page size change event', pageNum, delta
|
||||
origposition = angular.copy scope.position
|
||||
#console.log 'orig position', JSON.stringify(origposition)
|
||||
if pageNum - 1 < origposition.page && delta != 0
|
||||
currentScrollTop = element.scrollTop()
|
||||
console.log 'adjusting scroll from', currentScrollTop, 'by', delta
|
||||
scope.adjustingScroll = true
|
||||
element.scrollTop(currentScrollTop + delta)
|
||||
|
||||
element.on 'scroll', () ->
|
||||
#console.log 'scroll event', element.scrollTop(), 'adjusting?', scope.adjustingScroll
|
||||
#scope.scrollPosition = element.scrollTop()
|
||||
|
|
Loading…
Reference in a new issue