Famo.us view template
var Engine = famous.core.Engine;
var Surface = famous.core.Surface;
var View = famous.core.View;
var Modifier = famous.core.Modifier;
var MyView = function(){
// Run View as constructor first
View.call(this, arguments);
this.rootMod = new Modifier({
size: this.options.size
})
this.mainNode = this.add(this.rootMod)
_createSurface.call(this);
}
// Make the prototype have all the functions of View.prototype
MyView.prototype = Object.create(View.prototype);
MyView.prototype.constructor = MyView;
MyView.DEFAULT_OPTIONS = {
size: [100, 100]
};
function _createSurface(){
var surface = new Surface({
size: this.options.size,
properties: {
backgroundColor: 'red'
}
})
this.mainNode.add(surface);
}
// Runtime
var context = Engine.createContext()
var view = new MyView();
context.add(view);