mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
support pdf double click
This commit is contained in:
parent
4c0f3c55d7
commit
1284ce613c
5 changed files with 23 additions and 9 deletions
|
@ -64,12 +64,8 @@ define [
|
||||||
scope.flashControls = false
|
scope.flashControls = false
|
||||||
, 1000
|
, 1000
|
||||||
|
|
||||||
# element.find(".pdfjs-viewer").scroll () ->
|
scope.$on 'pdfDoubleClick', (event, e) ->
|
||||||
# scope.position = pdfListView.getPdfPosition(true)
|
scope.dblClickCallback?(page: e.page - 1, offset: { top: e.y, left: e.x })
|
||||||
|
|
||||||
onDoubleClick = (e) ->
|
|
||||||
console.log 'double click event'
|
|
||||||
scope.dblClickCallback?(page: e.page, offset: { top: e.y, left: e.x })
|
|
||||||
|
|
||||||
scope.$watch "pdfSrc", (url) ->
|
scope.$watch "pdfSrc", (url) ->
|
||||||
if url
|
if url
|
||||||
|
@ -146,7 +142,7 @@ define [
|
||||||
#console.log 'got a resize event', event, e
|
#console.log 'got a resize event', event, e
|
||||||
|
|
||||||
template: """
|
template: """
|
||||||
<div data-pdf-viewer class="pdfjs-viewer" pdf-src='pdfSrc' position='position' scale='scale' highlights='highlights' dbl-click-callback='dblClickCallback' please-jump-to='pleaseJumpTo'></div>
|
<div data-pdf-viewer class="pdfjs-viewer" pdf-src='pdfSrc' position='position' scale='scale' highlights='highlights' please-jump-to='pleaseJumpTo'></div>
|
||||||
<div class="pdfjs-controls" ng-class="{'flash': flashControls }">
|
<div class="pdfjs-controls" ng-class="{'flash': flashControls }">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a href
|
<a href
|
||||||
|
|
|
@ -82,6 +82,19 @@ define [
|
||||||
else if !newVisible && oldVisible
|
else if !newVisible && oldVisible
|
||||||
pausePage()
|
pausePage()
|
||||||
|
|
||||||
|
element.on 'dblclick', (e) ->
|
||||||
|
offset = $(element).find('.pdf-canvas').offset()
|
||||||
|
dx = e.pageX - offset.left
|
||||||
|
dy = e.pageY - offset.top
|
||||||
|
scope.document.getPdfViewport(scope.page.pageNum).then (viewport) ->
|
||||||
|
pdfPoint = viewport.convertToPdfPoint(dx, dy);
|
||||||
|
event = {
|
||||||
|
page: scope.page.pageNum
|
||||||
|
x: pdfPoint[0],
|
||||||
|
y: viewport.viewBox[3] - pdfPoint[1]
|
||||||
|
}
|
||||||
|
scope.$emit 'pdfDoubleClick', event
|
||||||
|
|
||||||
highlightsLayer = new pdfHighlights({
|
highlightsLayer = new pdfHighlights({
|
||||||
highlights: highlightsElement
|
highlights: highlightsElement
|
||||||
})
|
})
|
||||||
|
|
|
@ -116,7 +116,7 @@ define [
|
||||||
# console.log 'scale is undefined, returning'
|
# console.log 'scale is undefined, returning'
|
||||||
return
|
return
|
||||||
|
|
||||||
canvas = $('<canvas class="pdf-canvas-new"></canvas>')
|
canvas = $('<canvas class="pdf-canvas pdf-canvas-new"></canvas>')
|
||||||
|
|
||||||
viewport = page.getViewport (scale)
|
viewport = page.getViewport (scale)
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,12 @@ define [
|
||||||
textDiv.style.fontFamily = style.fontFamily
|
textDiv.style.fontFamily = style.fontFamily
|
||||||
textDiv.textContent = geom.str
|
textDiv.textContent = geom.str
|
||||||
|
|
||||||
|
textDiv.ondblclick = (e) ->
|
||||||
|
if (window.getSelection)
|
||||||
|
window.getSelection().removeAllRanges();
|
||||||
|
else if (document.selection)
|
||||||
|
document.selection.empty();
|
||||||
|
|
||||||
# |fontName| is only used by the Font Inspector. This test will succeed
|
# |fontName| is only used by the Font Inspector. This test will succeed
|
||||||
# when e.g. the Font Inspector is off but the Stepper is on, but it's
|
# when e.g. the Font Inspector is off but the Stepper is on, but it's
|
||||||
# not worth the effort to do a more accurate test.
|
# not worth the effort to do a more accurate test.
|
||||||
|
|
|
@ -206,7 +206,6 @@ define [
|
||||||
"highlights": "="
|
"highlights": "="
|
||||||
"position": "="
|
"position": "="
|
||||||
"scale": "="
|
"scale": "="
|
||||||
"dblClickCallback": "="
|
|
||||||
"pleaseJumpTo": "="
|
"pleaseJumpTo": "="
|
||||||
}
|
}
|
||||||
template: """
|
template: """
|
||||||
|
|
Loading…
Reference in a new issue