Instantly share code, notes, and snippets.

Embed
What would you like to do?
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