question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Question about scaleToFit behavior

See original GitHub issue

Hello! I was hoping to use the scaleToFit option on Text to shrink the font-size of a number if it was longer than the space available to display it. Unfortunately, it appears that the behavior of scaleToFit scales the size of the text up as well.

Is there an existing workaround to do what I need via Text (only shrink the size if it is too long)? If not, would you be open to a PR that adds this option?

Though, I am not certain the best way to add it. Adding a second prop seems somewhat clunky. Updating the existing prop to have shrink-only (or something similar) would be more ergonomic, but might be awkward to do in a backward-compatible way.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kyythanecommented, Oct 25, 2021

If I get time, Iā€™ll make an update to the demo later today. I guess the easiest change would be replacing the checkbox with a dropdown.

1reaction
williastercommented, Oct 21, 2021

Hey @kyythane šŸ‘‹ thanks for checking out visx. I canā€™t think of a workaround for this at the moment, itā€™s not exposed in Text but you might be able to leverage the useText hook directly. It might still be a little bit tricky since this is implemented with a transform, so a PR might be the best way to add it cleanly.

Iā€™m definitely happy to review a PR! modifying shrinkToFit: boolean to something like shrinkToFit: boolean | 'shrink-only' seems like it could be a good approach to me šŸ‘ I agree keeping a single prop sounds good and I donā€™t think itā€™d be breaking šŸ’„ since it would still accept true/false.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScaleToFit does not work - Stack Overflow
I have problems with the ScaletoFit method. I Have a UIPageViewController ... The question is: Why does the ScaleAspectFit-Method not work?
Read more >
Scale to Fit issues with tabs - EFI Communities
There should be 4 images attached to this thread/question. The initial image is simply displaying "scale to fit" has yet to be selected...
Read more >
"Scale to fit Paper Size" is not working - Microsoft Community
To answer your question, the scale to fit function is not working. ... Can you replicate this behavior? Any suggestions?
Read more >
Dynamic Sizing and Responsiveness for Learnosity Questions
Question Type Minā€‘Width Minā€‘Height Match List 300px 300px Multiple Choice Question ā€‘ Standard 100px 110px Multiple Choice Question ā€‘ Block UI 100px 130px
Read more >
object-fit - CSS: Cascading Style Sheets - MDN Web Docs
The object-fit CSS property sets how the content of a replaced element, such as an or , should be resized to fit its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found