mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
working on zoom/fit buttons
This commit is contained in:
parent
6c1cee1431
commit
a15ee57d77
2 changed files with 22 additions and 12 deletions
|
@ -128,24 +128,31 @@ define [
|
||||||
# , 1000
|
# , 1000
|
||||||
|
|
||||||
scope.fitToHeight = () ->
|
scope.fitToHeight = () ->
|
||||||
# pdfListView.setToFitHeight()
|
scale = angular.copy (scope.scale)
|
||||||
|
scale.scaleMode = 'scale_mode_fit_height'
|
||||||
|
scope.scale = scale
|
||||||
|
|
||||||
scope.fitToWidth = () ->
|
scope.fitToWidth = () ->
|
||||||
# pdfListView.setToFitWidth()
|
scale = angular.copy (scope.scale)
|
||||||
|
scale.scaleMode = 'scale_mode_fit_width'
|
||||||
|
scope.scale = scale
|
||||||
|
|
||||||
scope.zoomIn = () ->
|
scope.zoomIn = () ->
|
||||||
# scale = pdfListView.getScale()
|
scale = angular.copy (scope.scale)
|
||||||
# pdfListView.setScale(scale * 1.2)
|
scale.scaleMode = 'scale_mode_value'
|
||||||
|
scale.scale = scale.scale * 1.2
|
||||||
|
scope.scale = scale
|
||||||
|
|
||||||
scope.zoomOut = () ->
|
scope.zoomOut = () ->
|
||||||
# scale = pdfListView.getScale()
|
scale = angular.copy (scope.scale)
|
||||||
# pdfListView.setScale(scale / 1.2)
|
scale.scaleMode = 'scale_mode_value'
|
||||||
|
scale.scale = scale.scale / 1.2
|
||||||
|
scope.scale = scale
|
||||||
|
|
||||||
if attrs.resizeOn?
|
if attrs.resizeOn?
|
||||||
for event in attrs.resizeOn.split(",")
|
for event in attrs.resizeOn.split(",")
|
||||||
scope.$on event, (e) ->
|
scope.$on event, (e) ->
|
||||||
console.log 'got a resize event', event, e
|
console.log 'got a resize event', event, e
|
||||||
# pdfListView.onResize()
|
|
||||||
|
|
||||||
template: """
|
template: """
|
||||||
<div data-pdf-viewer class="pdfjs-viewer" pdf-src='pdfSrc' position='position' scale='scale'></div>
|
<div data-pdf-viewer class="pdfjs-viewer" pdf-src='pdfSrc' position='position' scale='scale'></div>
|
||||||
|
|
|
@ -61,7 +61,7 @@ app.controller 'pdfViewerController', ['$scope', '$q', 'PDFRenderer', '$element'
|
||||||
@redraw = (position) ->
|
@redraw = (position) ->
|
||||||
console.log 'in redraw'
|
console.log 'in redraw'
|
||||||
console.log 'reseting pages array for', $scope.numPages
|
console.log 'reseting pages array for', $scope.numPages
|
||||||
console.log 'position is', position
|
console.log 'position is', position.page, position.offset
|
||||||
$scope.pages = ({
|
$scope.pages = ({
|
||||||
pageNum: i
|
pageNum: i
|
||||||
} for i in [1 .. $scope.numPages])
|
} for i in [1 .. $scope.numPages])
|
||||||
|
@ -152,9 +152,10 @@ app.controller 'pdfViewerController', ['$scope', '$q', 'PDFRenderer', '$element'
|
||||||
return newPosition
|
return newPosition
|
||||||
|
|
||||||
@computeOffset = (page, position) ->
|
@computeOffset = (page, position) ->
|
||||||
|
console.log 'computing offset for', page, position
|
||||||
element = page.element
|
element = page.element
|
||||||
pageTop = $(element).offset().top - $(element).parent().offset().top
|
pageTop = $(element).offset().top - $(element).parent().offset().top
|
||||||
console.log('top of page scroll is', pageTop)
|
console.log('top of page scroll is', pageTop, 'vs', page.elemTop)
|
||||||
console.log('inner height is', $(element).innerHeight())
|
console.log('inner height is', $(element).innerHeight())
|
||||||
offset = position.offset
|
offset = position.offset
|
||||||
# convert offset to pixels
|
# convert offset to pixels
|
||||||
|
@ -163,7 +164,7 @@ app.controller 'pdfViewerController', ['$scope', '$q', 'PDFRenderer', '$element'
|
||||||
pageOffset = viewport.convertToViewportPoint(offset.left, offset.top)
|
pageOffset = viewport.convertToViewportPoint(offset.left, offset.top)
|
||||||
console.log 'addition offset =', pageOffset
|
console.log 'addition offset =', pageOffset
|
||||||
console.log 'total', pageTop + pageOffset[1]
|
console.log 'total', pageTop + pageOffset[1]
|
||||||
Math.round(pageTop + pageOffset[1] + 10) ## 10 is margin
|
Math.round(pageTop + pageOffset[1]) ## 10 is margin
|
||||||
|
|
||||||
@setPdfPosition = (page, position) ->
|
@setPdfPosition = (page, position) ->
|
||||||
console.log 'required pdf Position is', position
|
console.log 'required pdf Position is', position
|
||||||
|
@ -187,7 +188,9 @@ app.directive 'pdfViewer', ['$q', '$timeout', ($q, $timeout) ->
|
||||||
"dblClickCallback": "="
|
"dblClickCallback": "="
|
||||||
}
|
}
|
||||||
template: """
|
template: """
|
||||||
|
<div>
|
||||||
<div data-pdf-page class='pdf-page-container plv-page-view page-view' ng-repeat='page in pages'></div>
|
<div data-pdf-page class='pdf-page-container plv-page-view page-view' ng-repeat='page in pages'></div>
|
||||||
|
<div>
|
||||||
"""
|
"""
|
||||||
link: (scope, element, attrs, ctrl) ->
|
link: (scope, element, attrs, ctrl) ->
|
||||||
console.log 'in pdfViewer element is', element
|
console.log 'in pdfViewer element is', element
|
||||||
|
@ -203,7 +206,7 @@ app.directive 'pdfViewer', ['$q', '$timeout', ($q, $timeout) ->
|
||||||
element.innerWidth()
|
element.innerWidth()
|
||||||
element.innerHeight()
|
element.innerHeight()
|
||||||
element.offset().top
|
element.offset().top
|
||||||
]
|
]
|
||||||
|
|
||||||
doRescale = (scale) ->
|
doRescale = (scale) ->
|
||||||
console.log 'doRescale', scale
|
console.log 'doRescale', scale
|
||||||
|
@ -244,7 +247,7 @@ app.directive 'pdfViewer', ['$q', '$timeout', ($q, $timeout) ->
|
||||||
return
|
return
|
||||||
#console.log 'not from auto scroll'
|
#console.log 'not from auto scroll'
|
||||||
scope.position = ctrl.getPdfPosition()
|
scope.position = ctrl.getPdfPosition()
|
||||||
console.log 'position is', scope.position
|
console.log 'position is', scope.position.page, scope.position.offset
|
||||||
scope.$apply()
|
scope.$apply()
|
||||||
|
|
||||||
scope.$watch 'pdfSrc', (newVal, oldVal) ->
|
scope.$watch 'pdfSrc', (newVal, oldVal) ->
|
||||||
|
|
Loading…
Reference in a new issue