measure.mjs 504 B

12345678910111213141516171819
  1. function updateSVGDimensions(instance, renderState) {
  2. try {
  3. renderState.dimensions =
  4. typeof instance.getBBox === "function"
  5. ? instance.getBBox()
  6. : instance.getBoundingClientRect();
  7. }
  8. catch (e) {
  9. // Most likely trying to measure an unrendered element under Firefox
  10. renderState.dimensions = {
  11. x: 0,
  12. y: 0,
  13. width: 0,
  14. height: 0,
  15. };
  16. }
  17. }
  18. export { updateSVGDimensions };