Skip to content

Commit

Permalink
Fixes STRML#52 : introduce new option to ignore zero inner width or h…
Browse files Browse the repository at this point in the history
…eight. Default is false to keep current behavior.
  • Loading branch information
JACQUES Francois authored and JACQUES Francois committed Aug 6, 2021
1 parent 7a1eed6 commit c9c4a3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions textFit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
reProcess: true, // if true, textFit will re-process already-fit nodes. Set to 'false' for better performance
widthOnly: false, // if true, textFit will fit text to element width, regardless of text height
alignVertWithFlexbox: false, // if true, textFit will use flexbox for vertical alignment
ignoreZeroSize: false, // if true, textFit will not fail if inner width or height is 0
};

return function textFit(els, options) {
Expand Down Expand Up @@ -100,6 +101,9 @@

// Don't process if we can't find box dimensions
if (!originalWidth || (!settings.widthOnly && !originalHeight)) {
if (settings.ignoreZeroSize) {
return
}
if(!settings.widthOnly)
throw new Error('Set a static height and width on the target element ' + el.outerHTML +
' before using textFit!');
Expand Down
2 changes: 1 addition & 1 deletion textFit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9c4a3c

Please sign in to comment.