enyo framework to integrate which raphael

91 views Asked by At

I'm trying to integrate Raphael with enyo.js to create SVG component using Raphael instead of through enyo so i can use some of the Raphael functionality. I would like to replace the div that is rendered by default with it child component svg, i have created below jsfiddle. Can anyone help me fix it?

http://jsfiddle.net/stackit/uzjafamo/8/

Code

enyo.kind({
    name: "Board",
    kind: "enyo.Control",
    paper: null,
    create: function(){
       this.inherited(arguments);
    },
    rendered: function(){
         this.inherited(arguments);  
        if(this.hasNode()){
            paper = Raphael(this.hasNode().id, 100, 100);
          }

    }
})


enyo.kind({
    name: "pages",
    kind: "enyo.Control",
    create: function(){
        this.inherited(arguments);
        this.loadView();
    },
    loadView: function(){
        if(!this.$.board){
            var com = this.createComponent({
                name: "board",
                kind: "Board",
            },{
                owner: this
            });
            com.render();
        }
    }
});



new pages().renderInto(document.getElementById("cans"));
1

There are 1 answers

9
Brak On BEST ANSWER

I looked at your fiddle and saw a little bit that could be improved. The jsFiddle container was giving me some trouble though initially, until I forked it for some reason.

Here's what I came up with: http://jsfiddle.net/Djspaceg/5qyLej05/4/

enyo.kind({
    name: "Board",
    kind: "enyo.Control",
    paper: null,
    create: function () {
        this.inherited(arguments);
    },
    rendered: function () {
        this.inherited(arguments);
        if (this.hasNode() && !this.paper) {
            this.generateRaphael();
        }
    },
    generateRaphael: function () {
        this.paper = Raphael(this.hasNode().id, 100, 100);
    }
});

enyo.kind({
    name: "pages",
    kind: "enyo.Control",
    create: function () {
        this.inherited(arguments);
        this.loadView();
    },
    loadView: function () {
        if (!this.$.board) {
            var com = this.createComponent({
                name: "board",
                kind: "Board",
            });
            com.render();
        }
    }
});

new pages().renderInto(document.getElementById("cans"));

It just generates an empty Raphael canvas.

Cheers!