mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-06 00:11:24 +00: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
|
||||
, 1000
|
||||
|
||||
# element.find(".pdfjs-viewer").scroll () ->
|
||||
# scope.position = pdfListView.getPdfPosition(true)
|
||||
|
||||
onDoubleClick = (e) ->
|
||||
console.log 'double click event'
|
||||
scope.dblClickCallback?(page: e.page, offset: { top: e.y, left: e.x })
|
||||
scope.$on 'pdfDoubleClick', (event, e) ->
|
||||
scope.dblClickCallback?(page: e.page - 1, offset: { top: e.y, left: e.x })
|
||||
|
||||
scope.$watch "pdfSrc", (url) ->
|
||||
if url
|
||||
|
@ -146,7 +142,7 @@ define [
|
|||
#console.log 'got a resize event', event, e
|
||||
|
||||
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="btn-group">
|
||||
<a href
|
||||
|
|
|
@ -82,6 +82,19 @@ define [
|
|||
else if !newVisible && oldVisible
|
||||
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({
|
||||
highlights: highlightsElement
|
||||
})
|
||||
|
|
|
@ -116,7 +116,7 @@ define [
|
|||
# console.log 'scale is undefined, returning'
|
||||
return
|
||||
|
||||
canvas = $('<canvas class="pdf-canvas-new"></canvas>')
|
||||
canvas = $('<canvas class="pdf-canvas pdf-canvas-new"></canvas>')
|
||||
|
||||
viewport = page.getViewport (scale)
|
||||
|
||||
|
|
|
@ -182,6 +182,12 @@ define [
|
|||
textDiv.style.fontFamily = style.fontFamily
|
||||
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
|
||||
# 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.
|
||||
|
|
|
@ -206,7 +206,6 @@ define [
|
|||
"highlights": "="
|
||||
"position": "="
|
||||
"scale": "="
|
||||
"dblClickCallback": "="
|
||||
"pleaseJumpTo": "="
|
||||
}
|
||||
template: """
|
||||
|
|
Loading…
Reference in a new issue