datchley / react-scale-text

A React library to keep an element's text scaled to fit it's container
MIT License
54 stars 18 forks source link

While resizing from max height to min height the font is not resizing. #20

Open ghost opened 4 years ago

ghost commented 4 years ago

I am facing an issue where when I resize an html panel from 400px height to 200px by keeping width as constant then the Font Size does not resize as per the new height.

Below are my props passed minFontSize = 12 maxFontSize = 600 and widthOnly = false

In order to solve this issue I had done a change in the file src/get-fillsize.js function - getFillSize I have changed this line

let fontSize = Math.min( Math.max(Math.min(Number(el.offsetWidth) / (factor * 10), maxFontSize), minFontSize) );

to let fontSize = Math.min( Math.max(Math.min(Number(el.offsetHeight) / (factor * 10), maxFontSize), minFontSize) ); In order to solve my issue and is working I need help from you whether I can patch this as hotfix in your new release.