Skip to content

Commit 671092b

Browse files
committed
Fix - detect element width/height from style
If HTML layout does not display main element and therefore detected dimensions are 0, try to extract width and height from style. In many practical situation it will be perfect match
1 parent 1286902 commit 671092b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/base/BasePainter.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,14 @@ class BasePainter {
613613

614614
rect.changed = false;
615615

616+
if (!rect.width && !rect.height && !main.empty() && main.attr('style')) {
617+
const ws = main.style('width'), hs = main.style('height');
618+
if (isStr(ws) && isStr(hs) && ws.match(/^\d+px$/) && hs.match(/^\d+px$/)) {
619+
rect.width = parseInt(ws.slice(0, ws.length-2));
620+
rect.height = parseInt(hs.slice(0, hs.length-2));
621+
}
622+
}
623+
616624
if (old_h && old_w && (old_h > 0) && (old_w > 0)) {
617625
if ((old_h !== rect.height) || (old_w !== rect.width))
618626
rect.changed = (check_level > 1) || (rect.width / old_w < 0.99) || (rect.width / old_w > 1.01) || (rect.height / old_h < 0.99) || (rect.height / old_h > 1.01);

0 commit comments

Comments
 (0)