Connect with:
About Me
Alessandro Annini
I'm a freelance developer currently working at Leaff.it/ I really love famo.us framework and its amazing potential and if you're like me, and you want the web to win, please share some snippet of code for the community and grow faster with us
Categories
Meta
Famo.us Code | Image Continuos Carousel
189
post-template-default,single,single-post,postid-189,single-format-standard,ajax_updown_fade,page_not_loaded,,qode-theme-ver-6.2.1

Image Continuos Carousel

23 Jun Image Continuos Carousel

Image Continuos Carousel

Thanks to John Traver

 

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);