Integrating Enyo and Snap.svg

46 Views Asked by At

I am trying to integrate snap.svg in to Enyo and having a problem. The code below works, until render() is called. The problem seems to be that generateHtml in HTMLStringDelegate.js doesn't know about the content added by snap.svg and clears out "svg".

Uncomment "this.render();" to see it.

http://jsfiddle.net/Kloodge/g7MLS/2031/

var ready = require('enyo/ready'),
    kind = require('enyo/kind'),
    Toolbar = require('onyx/Toolbar'),
    Application = require('enyo/Application');

ready(function() {
    var MySample = kind({
        name: "MySample",
        paper: null,
        components: [
            {kind: Toolbar, content: "Your sample here."},
            {tag: "svg", name:"svg"}
        ],
        rendered: function(){
            this.inherited(arguments);
            if(!this.paper && this.$.svg.hasNode()){
                this.paper = Snap("#"+this.$.svg.hasNode().id);
                circle = this.paper.circle(10, 10, 10);
                circle.attr({
                    fill: "#bada55",
                    stroke: "#000",
                    strokeWidth: 5,
               });
               //this.render();
            }
        }
    });

    new Application({view: MySample});
});

Is there any way to do this short of adding the content statically to "svg"?

0

There are 0 best solutions below