scroll select annotation into view

This commit is contained in:
j 2019-01-25 16:38:45 +05:30
parent 0bfbebb21d
commit d97d396ef3
1 changed files with 8 additions and 1 deletions

View File

@ -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) {