Skip to content

Instantly share code, notes, and snippets.

@pusherman
Last active August 29, 2015 14:00
Show Gist options
  • Save pusherman/a875b35aaacfcb333f57 to your computer and use it in GitHub Desktop.
Save pusherman/a875b35aaacfcb333f57 to your computer and use it in GitHub Desktop.
Reproduce Issue #30
'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);
@pusherman
Copy link
Author

In this example it could also be considered a feature as a more efficient way to produce the lyrics to the happy birthday song ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment