Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add SVGPan support to raphael
    primarykey
    data
    text
    <p>i'm using a library that creates svg content using raphael library. I would now like to add zooming functionality. I found following library:</p> <p><a href="http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/" rel="nofollow">http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/</a></p> <p>This is how the svg part looks:</p> <pre><code>&lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1"&gt; //...the image </code></pre> <p>The issue is that this library expects a script tag and a g tag surrounding the whole image. It should look like this after manipulation:</p> <pre><code>&lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"&gt; &lt;script xlink:href="SVGPan.js"/&gt; &lt;g id="viewport" transform="translate(200,200)"&gt; ...//the image &lt;/g&gt; </code></pre> <p>I would need to add the script tag but the real problem is to put a g element with id="viewport" around the whole rest of the image. How can i do that with JQuery or plan JavaScript?</p> <p>EDIT:</p> <p>I got a bit ahead of myself. It turns out that adding the script tag does not seem to work:</p> <pre><code>var svg = $('svg'); svg.attr('xmlns:xlink', 'http://www.w3.org/1999/xlink'); // else error in firefox with links var scriptElement = document.createElementNS('http://www.w3.org/2000/svg','script'); scriptElement.setAttribute('xlink:href','js/SVGPan.js'); svg.prepend(scriptElement); </code></pre> <p>I don't get an error and the script runs completely but the tag is not added. I have verified that $('svg') selects the desired element and I can do stuff with it except prepending the script tag for whatever resaon i do not understand.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload