Using the API, you access a multitude of methods and events allowing you to push your possibilities further.

To access the different methods, all you have to do is invoke the main instance and access the subclass you want to use :

var instance = new AsukaDesigner('#myId'); // Create an instance of the main plugin class

instance.designer // Access the designer class and all his methods
instance.layout // Access the layout class and all his methods
instance.util // Access the util class and all his methods


Let’s imagine that I want to add a view, I just have to call the addView method of the layout subclass, this method takes as first parameter the name of the view, second an object containing the width and height of the view :

var instance = new AsukaDesigner('#myId');
instance.layout.addView('Front', /* width */ 500, /* height */ 500})

Now imagine that I want to add a text, I just need to call the addText method of the designer subclass, this method takes as first parameter the text to add, second an object containing additional parameters, third the view where will be added the text (current view if not defined) :

var instance = new AsukaDesigner('#myId');
instance.designer.addText('Example text')


To listen to an event, access the main plugin instance directly and call the on method, this method takes as the first parameter the event to listen to, second, the callback function :

var instance = new AsukaDesigner('#myId');

instance.on('ready', function(){
    console.log('Ready for anything')

instance.on('addText', function(text){
    console.log(`The following text has been added : ${text}`)
Was this article helpful to you? Yes No

How can we help?