Skip to content

Commit

Permalink
fix: hide elements with no dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpedemonte committed Jul 25, 2024
1 parent 24da19c commit 8f8750e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,14 @@ function adjustTextDivs(
const expectedHeight = textItem.height * scale;
const actualHeight = textDivElm.getBoundingClientRect().height;

/**
* Retrieve scale definition from within `transform` style rule
*/
// hide elements that don't have dimensions
if (expectedHeight === 0 || expectedWidth === 0) {
textDivElm.style.visibility = 'hidden';
textDivElm.style.transform = '';
continue;
}

// retrieve scale definition from within `transform` style rule
function getScale(element: HTMLElement, type: 'x' | 'y'): number | null {
const pattern = type === 'x' ? scaleXPattern : scaleYPattern;
const match = element.style.transform?.match(pattern);
Expand Down

0 comments on commit 8f8750e

Please sign in to comment.