Last active
August 29, 2015 14:00
-
-
Save pusherman/a875b35aaacfcb333f57 to your computer and use it in GitHub Desktop.
Reproduce Issue #30
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
'use strict'; | |
var Engine = require("famous/core/Engine"); | |
var Modifier = require("famous/core/Modifier"); | |
var Surface = require("famous/core/Surface"); | |
var RenderController = require("famous/views/RenderController"); | |
var mainContext = Engine.createContext(); | |
var renderController = new RenderController(); | |
var surfaces = []; | |
var counter = 0; | |
for (var i = 0; i < 10; i++) { | |
surfaces.push(new Surface({ | |
content: "Surface: " + (i + 1), | |
size: [200, 200], | |
properties: { | |
backgroundColor: "hsl(" + (i * 360 / 10) + ", 100%, 50%)", | |
lineHeight: "200px", | |
textAlign: 'center' | |
} | |
})); | |
} | |
renderController.show(surfaces[0]); | |
Engine.on("click", function() { | |
var next = (counter++ + 1) % surfaces.length; | |
this.show(surfaces[next], null, function() { console.log('happy birthday to you') }); | |
}.bind(renderController)); | |
mainContext.add(new Modifier({origin: [.5, .5]})).add(renderController); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this example it could also be considered a feature as a more efficient way to produce the lyrics to the happy birthday song ;)