Created
June 23, 2014 16:10
-
-
Save john45traver/9440b2efd0f0a1744228 to your computer and use it in GitHub Desktop.
Endless looping of scrollview
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
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