Search code examples
javascripthtmlcanvaskineticjs

What is the difference between container() and getContent() in Kineticjs?


Having a Stage in Kineticjs:

var stage = new Kinetic.Stage({
    container : 'container',
    width : 500,
    height : 500
});

What is the difference between the following lines?

var container = stage.container();

and

var content = stage.getContent();

Solution

  • You supply the container div...KineticJS adds the content div to host all its operations.

    The container is the html div element you created to hold all the sub-elements that KineticJS will create to "do-its-thing".

    The content a child div that KineticJS creates inside your container element.

    After KineticJS executes, the content div is the one with class="kineticjs-content".