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.

Support for getBBox?

See original GitHub issue

Loving react-native-svg - thanks so much!

I am porting some code to React-Native that I originally wrote for the browser using React.js and SVG. Everything is working great so far, but I’ve run into a problem - I need to calculate the bounding box of various SVG groups (<g> elements).

To obtain the bounding box of a <g> element in a browser, it is enough to use a ref to get a callback with the mounted element, then invoke the SVG spec’s getBBox method on it, e.g.:

<g ref={(el)=>{console.log(el.getBBox())}}>
  <circle cx={100} cy={100} r={50}/>
  <circle cx={120} cy={80} r={60}/>
</g>

As far as I can tell there isn’t currently any support for getBBox in react-native-svg, so …

  1. Are there any plans to introduce this support? (if so, is there a rough timeline?)
  2. Is there a good alternative way to calculate the bounding box, taking into account transformations and such?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
msandcommented, Dec 9, 2018

You can also use UIManager.measure, closing now.

2reactions
maxkomarychevcommented, Apr 14, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

SVGGraphicsElement.getBBox() - Web APIs | MDN
The SVGGraphicsElement.getBBox() method allows us to determine the coordinates of the smallest rectangle in which the object fits.
Read more >
SVGGraphicsElement API: getBBox | Can I use... Support ...
The getBBox() method returns an empty DOMRect when there is no fill (bug 1019326). • This method doesn't work for <textPath> and <tspan>...
Read more >
getbbox VEX function - SideFX
Outputs the bounding box of the primitive in the given group. An empty primgroup string will include all primitives. The string supports Ad-hoc...
Read more >
getBBox - Popular Blocks - Mike Bostock
You can find thousands of notebooks on Observable to help you learn and get inspired. See my notebooks on Observable. → · See...
Read more >
How is the getBBox() SVGRect calculated? - Stack Overflow
SVG support in browsers is still a hit or miss, after 10 years. (Let alone SMIL... :( ). – fregante. Jun 5, 2011...
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