famous: scrollview within scrollview

ぐ巨炮叔叔 提交于 2019-12-03 21:13:38

I see you figured it out, but I thought I would post a clean working example for anyone that needed a starting point.. So here it is..

To answer the question, Yes, you needed to pipe your events from the surfaces to each of the scrollviews

var Engine              = require("famous/core/Engine");
var Surface             = require("famous/core/Surface");
var View                = require("famous/core/View");
var Scrollview          = require("famous/views/Scrollview");
var ContainerSurface    = require("famous/surfaces/ContainerSurface");

var context = Engine.createContext();

var surfaces1 = [];
var surfaces2 = [];

var scrollers = [];

scroll_v_cont = new ContainerSurface({
    size:[300,300],
    properties: { overflow: 'hidden' }
});

var scroll_v = new Scrollview({ direction: 1 });

scroll_v.sequenceFrom(scrollers);

scroll_v_cont.add(scroll_v);

var scroll_h1_cont = new ContainerSurface({
    size:[300,300],
    properties: {overflow: 'hidden'}
});


var scroll_h1 = new Scrollview({ direction: 0});

scroll_h1.sequenceFrom(surfaces1);

scroll_h1_cont.add(scroll_h1);


var scroll_h2_cont = new ContainerSurface({
    size:[300,300],
    properties: { overflow: 'hidden'}
})


var scroll_h2 = new Scrollview({ direction: 0})

scroll_h2.sequenceFrom(surfaces2);

scroll_h2_cont.add(scroll_h2);

scrollers.push(scroll_h1_cont);
scrollers.push(scroll_h2_cont);

for (var i = 0; i < 4; i++) {
    var surface1 = new Surface({
         content: "Surface: " + (i + 1),
         size: [300, 300],
         properties: {
             backgroundColor: "hsl(" + (i * 360 / 8) + ", 100%, 50%)",
             lineHeight: "200px",
             textAlign: "center"
         }
    });

    surface1.pipe(scroll_v);
    surface1.pipe(scroll_h1);
    surfaces1.push(surface1);

    var surface2 = new Surface({
         content: "Surface: " + (i + 1),
         size: [300, 300],
         properties: {
             backgroundColor: "hsl(" + (i * 360 / 8 + (360 / 8)*4) + ", 100%, 50%)",
             lineHeight: "200px",
             textAlign: "center"
         }
    });

    surface2.pipe(scroll_v);
    surface2.pipe(scroll_h2);
    surfaces2.push(surface2);

};

context.add(scroll_v_cont);

the famous-flex FlexScrollView supports vertical & horizontal scrolling restrictions when embedding one scrollview in another. It is described in more detail at the bottom of the FlexScrollView tutorial:

https://github.com/IjzerenHein/famous-flex/blob/master/tutorials/FlexScrollView.md

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!