Skip to content

Commit

Permalink
fix(missing-annotations): Fix annotations on zoom issue (#701)
Browse files Browse the repository at this point in the history
* fix(missing-annotations): Fix annotations on zoom issue

* fix(missing-annotations): Destroy all managers

* fix(missing-annotations): Address PR comments
  • Loading branch information
JChan106 authored Jul 24, 2023
1 parent 2389c85 commit 6f66b54
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/document/DocumentAnnotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ export default class DocumentAnnotator extends BaseAnnotator {
const pageReferenceEl = this.getPageReference(pageEl);
const managers = this.managers.get(pageNumber) || new Set();
const resinTags = { fileid: fileId, iscurrent: isCurrentFileVersion };
let destroyManagers = false;

// Destroy any managers that were attached to page elements that no longer exist
// If a referenced page element doesn't exist, destroy all managers to keep them in sync
managers.forEach(manager => {
if (!manager.exists(pageEl)) {
manager.destroy();
managers.delete(manager);
destroyManagers = true;
}
});
if (destroyManagers) {
managers.forEach(manager => {
manager.destroy();
});
managers.clear();
}

// Lazily instantiate managers as pages are added or re-rendered
if (managers.size === 0) {
Expand Down

0 comments on commit 6f66b54

Please sign in to comment.