javascript - Changing svg element position from its xml -


i have svg icons place in middle of svg circle in web page. use same javascript function snap images 1 not centered properly...

i tried put directly svg in html test (see http://jsfiddle.net/aop5znab/) can notice, ball placed correctly, not man, should on top left (like, below ball...).

as far know svg, position can changed transform attribut or directly in path (relativ or absolute path points). icon hasn't transform attribute think can path points positioning differently.

can tell me if i'm right ?

  • if yes, can change in xml of svg set top-left position (without transform please)
  • if no, what's problem ?

here svg :

<g style="fill:#808080">     <g fill="#0ea507">         <circle cx="75.042" cy="68.168999" r="4.3889999" fill="#0ea507" d="m 79.431,68.168999 c 79.431,70.592976 77.465978,72.557999 75.042,72.557999 72.618022,72.557999 70.653,70.592976 70.653,68.168999 70.653,65.745021 72.618022,63.779999 75.042,63.779999 77.465978,63.779999 79.431,65.745021 79.431,68.168999 z"/>         <g fill="#0ea507">             <g fill="#0ea507">                 <g fill="#0ea507">                     <polyline                         points="67.165,87.193 70.991,77.023 74.929,77.023"                         fill="#0ea507" />                     <path                         d="m 67.165,89.22 c 66.928,89.22 66.687,89.178 66.451,89.089 65.404,88.695 64.875,87.527 65.269,86.48 l 69.096,76.31 c 69.393,75.521 70.148,74.998 70.992,74.998 h 74.93 c 76.049,74.998 76.956,75.905 76.956,77.024 76.956,78.143 76.049,79.049 74.93,79.049 h 72.393 l 69.06,87.907 c 68.755,88.719 67.984,89.22 67.165,89.22 z"                         id="path3010"                         fill="#0ea507" />                 </g>                 <g                     fill="#0ea507">                     <polyline                         points="82.92,87.193 79.094,77.023 75.155,77.023"                         fill="#0ea507" />                     <path                         d="m 82.92,89.22 c 82.101,89.22 81.329,88.719 81.024,87.907 l 77.691,79.049 h 75.154 c 74.035,79.049 73.129,78.142 73.129,77.024 73.129,75.905 74.036,74.998 75.154,74.998 h 79.093 c 79.936,74.998 80.692,75.521 80.989,76.31 l 84.815,86.48 c 85.209,87.527 84.68,88.695 83.633,89.089 83.399,89.177 83.158,89.22 82.92,89.22 z"                         fill="#0ea507" />                 </g>             </g>             <path                 d="m 75.042,75.006 c 75.042,75.006 80.782,74.556 80.219,80.183 79.656,85.81 77.63,103.365 76.617,103.478 75.604,103.591 75.942,103.703 75.042,103.703 74.142,103.703 74.479,103.591 73.467,103.478 72.454,103.365 70.428,85.809 69.865,80.183 69.302,74.557 75.042,75.006 75.042,75.006 z"                 fill="#0ea507" />             </g>             </g>     </g> 

note : tried this didn't changed anything...

the best solution i've found use inkscape answered in thread : removing transforms in svg files

here's copy/past of steps proposed in answer :

remove transforms in inkscape

  1. open svg file in inkscape
  2. go edit > xml editor
  3. find transform attributes in layers , delete them

how move objects altogether without creating transform attributes

  1. ungroup grouped elements object > ungroup
  2. go edit > select in layers
  3. go object > transform

then in transform panel

  1. uncheck relative move , check apply each object separately
  2. set horizontal , vertical values according needs , click apply

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -