how to get bounding box or rect (getBBox()) for svg path in jquery -


i want getbbox() svg path in jquery. tried this

$("#"+ path id)[0].getbbox() -> returns x=0,y=0,width=0,height=0 

i have added path svg element. tried other element in svg, example text node in case returns bounding box value.

how can calculate bounding box path in svg?

<path id="container_svg_john_0" fill="none" stroke-width="3" stroke="url(#container_svg_john0gradient)" stroke-linecap="butt" stroke-linejoin="round" d="m -2390.2 -125.8888888888889 l 0 0 m 0 0 l 251.60000000000002 -45.77777777777778 m 251.60000000000002 -45.77777777777778 l 503.20000000000005 -11.444444444444445 m 503.20000000000005 -11.444444444444445 l 629 -183.11111111111111 "/> 

getbbox native svg method , isn't part of jquery need write

$("#"+ path id)[0].getbbox() 

example

if you're getting non-zero value example , 0 value in code there must else going on you've not shown us.

the causes path child of <defs> i.e. you're using indirectly in pattern or clippath or alternatively has display style of none in case wouldn't rendered have no bounding box.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -