Skip to content

Instantly share code, notes, and snippets.

@solomon-gumball
Last active August 29, 2015 14:15
Show Gist options
  • Save solomon-gumball/c3cd4e8f87490480ee6c to your computer and use it in GitHub Desktop.
Save solomon-gumball/c3cd4e8f87490480ee6c to your computer and use it in GitHub Desktop.
Scrollview w/ Sequential Layout
define(function(require, exports, module) {
var Engine = require('famous/core/Engine');
var Surface = require('famous/core/Surface');
var ScrollView = require('famous/views/ScrollView');
var SequentialLayout = require('famous/views/SequentialLayout');
var mainContext = Engine.createContext();
mainContext.setPerspective(1000);
// Create top surface
var topSurface = new Surface({ size: [undefined, 100], properties: { backgroundColor: 'pink' } });
// Create sequential layout and children
var sequentialLayout = new SequentialLayout({ direction: 0 });
var sequentialSurfaces = [];
sequentialSurfaces.push(new Surface({ size: [100, 100], properties: { backgroundColor: 'rgb(250, 171, 219)' } }));
sequentialSurfaces.push(new Surface({ size: [100, 100], properties: { backgroundColor: 'rgb(255, 100, 165)' } }));
sequentialSurfaces.push(new Surface({ size: [100, 100], properties: { backgroundColor: 'rgb(250, 43, 123)' } }));
sequentialLayout.sequenceFrom(sequentialSurfaces);
// Create bottom Surface
var bottomSurface = new Surface({ size: [undefined, 100], properties: { backgroundColor: 'pink' } });
// Create ScrollView and sequence from children
var scrollView = new ScrollView();
var items = [];
items.push(topSurface);
items.push(sequentialLayout);
items.push(bottomSurface);
scrollView.sequenceFrom(items);
// Add to main context
mainContext.add(scrollView);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment