Created
November 8, 2014 00:06
-
-
Save solomon-gumball/28c6ac175845447f1508 to your computer and use it in GitHub Desktop.
RenderController inAlignFrom and outAlignFrom test.
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
define(function(require, exports, module) { | |
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 context = Engine.createContext(); | |
var rc = new RenderController(); | |
// Set in and out align functions | |
rc.inAlignFrom( function(progress){ return [0, 1 - progress] }); | |
rc.outAlignFrom(function(progress){ return [0, -1 + progress] }); | |
// Push 30 renderables to array | |
var renderables = []; | |
for (var i = 0; i < 30; i++) { | |
renderables.push(new Surface({ | |
content: i.toString(), | |
properties: { | |
backgroundColor: 'pink', | |
fontSize: '40px', | |
color: 'white' | |
} | |
})); | |
} | |
// On spacebar show next renderable | |
var showIndex = 0; | |
Engine.on('keypress', function(e){ | |
if(e.which === 32) { | |
rc.show(renderables[++showIndex]); | |
} | |
}); | |
// Show first renderable | |
rc.show(renderables[0]); | |
// Create centering modifier | |
var centerMod = new Modifier({ | |
origin: [0.5, 0.5], | |
align: [0.5, 0.5], | |
size: [100, 100] | |
}); | |
context.add(centerMod).add(rc); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment