Skip to content

Instantly share code, notes, and snippets.

@kof
Created May 19, 2014 21:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kof/0713a751d96026283980 to your computer and use it in GitHub Desktop.
Save kof/0713a751d96026283980 to your computer and use it in GitHub Desktop.
famous scrollview
/* globals define */
define(function(require, exports, module) {
'use strict';
// import dependencies
var Engine = require('famous/core/Engine');
var Modifier = require('famous/core/Modifier');
var Transform = require('famous/core/Transform');
var Scrollview = require("famous/views/Scrollview");
var View = require('famous/core/View');
var Surface = require('famous/core/Surface');
var FlexibleLayout = require('famous/views/FlexibleLayout');
var mainContext = Engine.createContext()
function App() {
View.apply(this, arguments)
this.header = new Header()
this.content = new Content()
this.navigation = new View()
this.scrollview = new Scrollview()
this.scrollview.pipe(this)
this.add(this.scrollview)
this.scrollview.sequenceFrom([this.header, this.content])
;['header', 'content'].forEach(function(name) {
this[name].pipe(this.scrollview)
}, this)
}
App.prototype = Object.create(View.prototype)
function Header() {
View.apply(this, arguments)
this.surface = new Surface({
content: 'Header',
size: [undefined, 200],
properties: {
backgroundColor: 'red'
}
})
this.add(this.surface)
this.surface.pipe(this)
}
Header.prototype = Object.create(View.prototype)
function Content() {
View.apply(this, arguments)
this.surface = new Surface({
content: 'Content',
properties: {
backgroundColor: 'green'
}
})
this.add(this.surface)
this.surface.pipe(this)
}
Content.prototype = Object.create(View.prototype)
mainContext.add(new App());
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment