Skip to content

Instantly share code, notes, and snippets.

@mplatts
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mplatts/5d72063dfa56aa8c91bc to your computer and use it in GitHub Desktop.
Save mplatts/5d72063dfa56aa8c91bc to your computer and use it in GitHub Desktop.
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment