Last active
August 29, 2015 14:10
-
-
Save mplatts/5d72063dfa56aa8c91bc to your computer and use it in GitHub Desktop.
Famo.us view template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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