Skip to content

Instantly share code, notes, and snippets.

@john45traver
Created June 23, 2014 16:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john45traver/9440b2efd0f0a1744228 to your computer and use it in GitHub Desktop.
Save john45traver/9440b2efd0f0a1744228 to your computer and use it in GitHub Desktop.
Endless looping of scrollview
var Engine = require("famous/core/Engine");
var Surface = require("famous/core/Surface");
var Scrollview = require('famous/views/Scrollview');
mainContext = Engine.createContext();
scrollview = new Scrollview({direction:0});
var surfaces = [];
scrollview.sequenceFrom(surfaces);
var cellCount = 10;
var cellWidth = 400;
for (var i = 0, temp; i < cellCount; i++) {
temp = new Surface({
content: "Surface: " + (i + 1),
size: [cellWidth, 400],
properties: {
backgroundColor: "hsl(" + (i * 360 / 40) + ", 100%, 50%)",
lineHeight: "200px",
textAlign: "center"
}
});
surfaces.push(temp);
}
var time = (new Date).getTime();
scrollview._scroller.positionFrom(function(){
var position = (((new Date).getTime() - time) / 2.0) % ((cellCount*cellWidth) - mainContext.getSize()[0]);
return position;
});
mainContext.add(scrollview);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment