I'd like a width property that is like a textbox width for alignment purposes
See original GitHub issueI’m attempting to use troika-three-text to draw multiline text entities of CAD files. I want to give it a specific textbox width for alignment purposes.
Say the maxWidth is 100, the alignment is center, and the maximum that any line actually covers is 50. Currently, the text produced by troika-three-text is centered as if the “text box” is 50 wide, not 100 wide. Thus it is shifted to the left of it’s intended position.
It seems like this might be an easy thing to do. This line of code uses maxLineWidth which is the longest line of text (not the explicitly set maxWidth). I propose we add a width
field to the options that effectively forced maxLineWidth to the given value.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
CSS Box Alignment - CSS: Cascading Style Sheets | MDN
In this example using Grid Layout, there is extra space in the grid container after laying out the fixed width tracks on the...
Read more >C38: Using CSS width, max-width and flexbox to fit labels and ...
Define the width and max-width property for labels and inputs so they enlarge or shrink in the available space and respond to zoom...
Read more >c# - Bootstrap textbox width and alignment changes when ...
When I minimize the window the textbox appears on top of other controls and width of the textbox changes too. I tried below...
Read more >How to Align Labels Next to Inputs - W3docs
Let's see an example, where we also add placeholder, id and name attributes on inputs and for attribute on labels. As a result,...
Read more >CSS · Bootstrap
Use .container for a responsive fixed width container. ... Predefined grid classes like .row and .col-xs-4 are available for quickly making grid layouts....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Got it, makes sense. It definitely sounds like this will work to get the position without a sync callback and bounding box. The only downside I can think of is that the position won’t reflect the original CAD anchor point anymore, but it’s probably not a big deal. Currently what I’m working on is only a viewer, though some people have been forking it to make it interactive and add features.
OK, if you run into issues let me know and I’ll think how to improve it for you.
But I do think that with your original example of a “textbox” with a fixed width of 100, this should give equivalent behavior without having to measure the text bounds:
You can just think of
anchorX
as what horizontal position in the text you want to remain stable. If you’re center-aligning text in a fixed-width box, you want that point to be the text’s center. And then you just position that anchor point at the fixed-width box’s centerpoint.