【问题标题】:Famo.us ScrollContainer not scrollingFamo.us ScrollContainer 不滚动
【发布时间】:2015-05-12 23:23:13
【问题描述】:
define(function(require, exports, module){
var View            = require('src/core/View');
var Surface         = require('src/core/Surface');
var ScrollContainer = require('src/views/ScrollContainer');

function ListView(){
    View.apply(this, arguments);
    _createContent.call(this);
}

ListView.prototype = Object.create(View.prototype);
ListView.prototype.constructor = ListView;
ListView.DEFAULT_OPTIONS = {
    data: []
}

function _createContent(){

    var sc = new ScrollContainer();
    var sequence = [];

    sc.sequenceFrom(sequence);

    for (var i = 0; i < this.options.data.length; i++) {
        var surface = new Surface({
            content: this.options.data[i].name,
            size: [undefined, 40],
            properties: {
                borderBottom: '1px solid #000',
                padding: '10px 15px'
            }
        });
        sequence.push(surface);
    };

    this.add(sc);
}

module.exports = ListView;
});

正如您从标题中看到的,我的问题是 Famo.us ScrollContainer 没有滚动。上面的代码用于添加一个可滚动的列表。该模块随后被包含在 PageView 中。 PageView 包含在 MainView 中,它有一个 RenderController 来显示或隐藏页面。该列表与传递给该模块的数据一起显示。唯一的问题是滚动。有什么想法吗?

【问题讨论】:

    标签: javascript famo.us


    【解决方案1】:

    surface 需要将事件通过管道传送到ScrollContainer

        for (var i = 0; i < this.options.data.length; i++) {
            var surface = new Surface({
                content: this.options.data[i].name,
                size: [undefined, 40],
                properties: {
                    borderBottom: '1px solid #000',
                    padding: '10px 15px'
                }
            });
            surface.pipe(sc);  // Pipe the Surface events to the ScrollContainer
            sequence.push(surface);
        };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多