Skip to content

Commit 0b85eb6

Browse files
Redraw highlights based on the annotatable container width instead of the window width
1 parent e42393e commit 0b85eb6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

highlight-helper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,15 @@ function Highlighter(options = hhDefaultOptions) {
724724
}
725725

726726
// Window resize
727-
let previousWindowWidth = window.innerWidth;
727+
let previousContainerWidth = this.annotatableContainer.clientWidth;
728728
const respondToWindowResize = () => {
729-
// Only respond if the width changed (ignore height changes)
730-
if (window.innerWidth === previousWindowWidth) return;
729+
// Only respond if the annotatable container width changed
730+
if (this.annotatableContainer.clientWidth === previousContainerWidth) return;
731731
if (options.drawingMode === 'svg') {
732732
this.drawHighlights();
733733
if (previousSelectionRange) updateSelectionUi('bounds');
734734
}
735-
previousWindowWidth = window.innerWidth;
735+
previousContainerWidth = this.annotatableContainer.clientWidth;
736736
}
737737
const debouncedRespondToWindowResize = debounce(() => respondToWindowResize(), Math.floor(Object.keys(highlightsById).length / 20));
738738
window.addEventListener('resize', debouncedRespondToWindowResize, { signal: controller.signal });

0 commit comments

Comments
 (0)