$(document).on('viewerLoaded', function() {
var docViewer = readerControl.docViewer;
var annotManager = docViewer.GetAnnotationManager();
var displayModeManager = docViewer.GetDisplayModeManager();
var $scrollView = $('#DocumentViewer');
docViewer.on('mouseMove', function(evt, originalEvt) {
var point = {
x: $scrollView.scrollLeft() + originalEvt.pageX,
y: $scrollView.scrollTop() + originalEvt.pageY
};
var displayMode = displayModeManager.GetDisplayMode();
// get the currently hovered page index
var page = displayMode.GetSelectedPages(point, point);
if (page.first === null) {
return;
}
var pageCoordinate = displayMode.WindowToPage(point, page.first);
// loop backwards so that the annotation that appears on top will be found first
var annotations = annotManager.GetAnnotationsList();
for (var i = annotations.length - 1; i >= 0; i--) {
var annot = annotations[i];
if (annot.GetPageNumber() - 1 === pageCoordinate.pageIndex) {
var currentZoom = docViewer.GetPageZoom(docViewer.GetCurrentPage() - 1);
if (annot.selectionModel.prototype.testSelection(annot, pageCoordinate.x, pageCoordinate.y, currentZoom)) {
console.log("hovering over " + annot.Id);
break;
}
}
}
});
});