0

Using svg.js I am able to import a fragment from an existing svg file and add it to the dom. However I am not able to then manipulate that element using svg.js. Here is my code.

$.get('img/sprite.svg', function (doc) {

        var figure = $(doc).find('g#figure')[0];       
        var figureHTML = figure.outerHTML;

        var added = draw.svg(figureHTML);
        added.transform({rotate: 90});
});

Here is the link to the docs for importing http://svgjs.dev/importing-exporting/ and the links for transforming http://svgjs.dev/manipulating/transforms/ I can't get any transformations to work on the imported element.

wout
  • 2,477
  • 2
  • 21
  • 32
voam
  • 1,006
  • 13
  • 24
  • did you doublecheck the generated svg? Which element will get the transformation? Transformation of `` dont work! – Fuzzyma Feb 19 '17 at 14:18

1 Answers1

0

Perhaps there is another way, but if one uses css selectors one can get a handle into the objects in question then the transformations work.

   var elements = SVG.select('g#figure')
                .transform({rotate: 90});

http://svgjs.dev/referencing/

wout
  • 2,477
  • 2
  • 21
  • 32
voam
  • 1,006
  • 13
  • 24