diff --git a/static/reader/pdf.js b/static/reader/pdf.js index 490c62d..8f47db0 100644 --- a/static/reader/pdf.js +++ b/static/reader/pdf.js @@ -53,10 +53,10 @@ function renderAnnotation(annotation) { if (!page.canvas) { setTimeout(function() { renderAnnotation(annotation) - }, 50) + }, 10) return } - var pageElement = page.canvas.parentElement; + var pageElement = page.canvas.parentElement.parentElement; var viewport = page.viewport; annotation.coords.forEach(function (rect) { var bounds = viewport.convertToViewportRectangle(rect); @@ -68,6 +68,7 @@ function renderAnnotation(annotation) { el.setAttribute('style', 'position: absolute; background-color: yellow;opacity:0.3;' + 'left:' + Math.min(bounds[0], bounds[2]) + 'px; top:' + Math.min(bounds[1], bounds[3]) + 'px;' + 'width:' + Math.abs(bounds[0] - bounds[2]) + 'px; height:' + Math.abs(bounds[1] - bounds[3]) + 'px;'); + el.addEventListener('click', function() { if (el.classList.contains('selected')) { deselectAnnotation(annotation.id)