diff options
| author | Jenny Yu <jennyyu212@outlook.com> | 2022-04-28 16:17:25 -0400 |
|---|---|---|
| committer | Jenny Yu <jennyyu212@outlook.com> | 2022-04-28 16:17:25 -0400 |
| commit | 83c615b1b9706818894ee74481afd4c2bf34fe61 (patch) | |
| tree | 6e6a242fdbe1d5c164fce9d0c1ae84b4423ed40c /src/client/views/nodes/LabelBigText.js | |
| parent | 9f62b6d1c9848439671065dac9ed79bc393c83fa (diff) | |
| parent | 15bc17cbbe3816ab78ce653105ddff06bce18c59 (diff) | |
Merge branch 'master' into recording-jenny
Diffstat (limited to 'src/client/views/nodes/LabelBigText.js')
| -rw-r--r-- | src/client/views/nodes/LabelBigText.js | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/client/views/nodes/LabelBigText.js b/src/client/views/nodes/LabelBigText.js index db43551d8..02c36c4bc 100644 --- a/src/client/views/nodes/LabelBigText.js +++ b/src/client/views/nodes/LabelBigText.js @@ -5,14 +5,14 @@ And from Jetroid/bigtext.js v1.0.0, September 2016 Usage: BigText("#myElement",{ - rotateText: {Number}, (null) - fontSizeFactor: {Number}, (0.8) - maximumFontSize: {Number}, (null) - limitingDimension: {String}, ("both") - horizontalAlign: {String}, ("center") - verticalAlign: {String}, ("center") - textAlign: {String}, ("center") - whiteSpace: {String}, ("nowrap") + rotateText: {Number}, (null) + fontSizeFactor: {Number}, (0.8) + maximumFontSize: {Number}, (null) + limitingDimension: {String}, ("both") + horizontalAlign: {String}, ("center") + verticalAlign: {String}, ("center") + textAlign: {String}, ("center") + whiteSpace: {String}, ("nowrap") }); @@ -28,6 +28,8 @@ fontSizeFactor: This option is used to give some vertical spacing for letters th maximumFontSize: maximum font size to use. +minimumFontSize: minimum font size to use. if font is calculated smaller than this, text will be rendered at this size and wrapped + limitingDimension: In which dimension the font size should be limited. Possible values: "width", "height" or "both". Defaults to both. Using this option with values different than "both" overwrites the element parent width or height. horizontalAlign: Where to align the text horizontally. Possible values: "left", "center", "right". Defaults to "center". @@ -154,6 +156,7 @@ export default function BigText(element, options) { width: element.offsetWidth, //Note: This is slightly larger than the jQuery version height: element.offsetHeight, }; + if (!box.width || !box.height) return element; if (options.rotateText !== null) { @@ -187,7 +190,20 @@ export default function BigText(element, options) { lineHeight = Math.floor(heightFactor * 1000); var fontSize = lineHeight * options.fontSizeFactor; - if (options.maximumFontSize !== null && fontSize > options.maximumFontSize) { + if (fontSize < options.minimumFontSize) { + parentStyle.display = "flex"; + parentStyle.alignItems = "center"; + style.whiteSpace = "pre-wrap"; + style.textAlign = "center"; + style.visibility = ""; + style.fontSize = "18px"; + style.lineHeight = "20px"; + style.top = ""; + style.left = ""; + style.margin = ""; + return element; + } + if (options.maximumFontSize && fontSize > options.maximumFontSize) { fontSize = options.maximumFontSize; lineHeight = fontSize / options.fontSizeFactor; } |
