Skip to content

Commit 9c2d97a

Browse files
Round width in resize observer to avoid unnecessary redraws
1 parent 71e163d commit 9c2d97a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

highlight-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,10 @@ function Highlighter(options = hhDefaultOptions) {
775775

776776
// Annotatable container resize (debounced)
777777
let computedStyle = window.getComputedStyle(this.annotatableContainer);
778-
let previousWidth = this.annotatableContainer.clientWidth - parseInt(computedStyle.getPropertyValue('padding-left')) - parseInt(computedStyle.getPropertyValue('padding-right'));
778+
let previousWidth = Math.round(this.annotatableContainer.clientWidth - parseInt(computedStyle.getPropertyValue('padding-left')) - parseInt(computedStyle.getPropertyValue('padding-right')));
779779
const resizeObserver = new ResizeObserver(debounce((entries) => {
780780
for (const entry of entries) {
781-
const width = entry.contentBoxSize[0].inlineSize;
781+
const width = Math.round(entry.contentBoxSize[0].inlineSize);
782782
// Only respond if the annotatable content width changed
783783
if (width !== previousWidth) {
784784
if (options.drawingMode === 'svg') this.drawHighlights();

0 commit comments

Comments
 (0)