diff --git a/static/reader/pdf.js b/static/reader/pdf.js index 6e095f1..15b4487 100644 --- a/static/reader/pdf.js +++ b/static/reader/pdf.js @@ -11,14 +11,21 @@ Ox.load({ console.log('got', event, 'data', data) if (event == 'selectAnnotation') { var annotation = annotations.filter(function(a) { return a.id == data.id })[0] + var delay = 0 if ( annotation && annotation.page && PDFViewerApplication.pdfViewer.currentPageNumber != annotation.page ) { - //FIXME: scroll into view PDFViewerApplication.pdfViewer.currentPageNumber = annotation.page; + delay = 250 } + setTimeout(function() { + var el = document.querySelector('.a' + annotation.id); + if (el) { + document.querySelector('#viewerContainer').scrollTop = el.offsetTop + el.parentElement.offsetTop - 64; + } + }, delay) selectAnnotation(data.id) } else if (event == 'addAnnotations') { data.annotations.forEach(function(annotation) {