你如何通过管道连接到另一个 require 模块中的对象
How do you pipe to an object in another require module
我在一个模块中有一个滚动视图,它加载从其他模块返回的视图。
包含滚动视图的模块:
define(function(require, exports, module) {
var View = require('famous/core/View');
var Utility = require('famous/utilities/Utility');
var Scrollview = require('famous/views/Scrollview');
var HomeView = require('views/HomeView');
var DescriptionView = require('views/DescriptionView');
var paginationView = new Scrollview({
direction: Utility.Direction.X
});
var AppViews = [
HomeView,
DescriptionView
];
paginationView.sequenceFrom(AppViews);
module.exports = paginationView;
});
这是模块代码
define(function(require, exports, module) {
var View = require('famous/core/View');
var Surface = require('famous/core/Surface');
var FlexScrollView = require('famous-flex/FlexScrollView');
var MainView = require('views/MainView');
var EventHandler = require('famous/core/EventHandler');
function HomeView() {
View.apply(this, arguments);
}
HomeView.prototype = Object.create(View.prototype);
HomeView.prototype.constructor = HomeView;
HomeView.DEFAULT_OPTIONS = {};
var homeView = new HomeView();
var scrollView = new FlexScrollView();
homeView.add(scrollView);
for (var i = 0, temp; i < 40; i++) {
var surface = new Surface({
content: "Surface: " + (i + 1),
size: [undefined, 200],
properties: {
backgroundColor: "hsl(" + (i * 360 / 40) + ", 100%, 50%)",
lineHeight: "200px",
textAlign: "center"
}
});
surface.pipe(scrollView);
// ... I want to pipe to the parent scrollview here ...
如何将表面从第二个模块传送到第一个模块中的滚动视图?我仍在学习整个事件管道,不确定我将如何在这里实施它。我知道,由于我是从著名的 View 模块继承的,所以我应该能够访问一些高级事件管理,但对于我的情况如何做我一无所知。
模块 HomeView
扩展了 Famo.us View
,因此您可以将表面通过管道传递给 HomeView
中的事件处理程序
// ... I want to pipe to the parent scrollview here ...
Surface.pipe(this._eventOutput);
我在一个模块中有一个滚动视图,它加载从其他模块返回的视图。
包含滚动视图的模块:
define(function(require, exports, module) {
var View = require('famous/core/View');
var Utility = require('famous/utilities/Utility');
var Scrollview = require('famous/views/Scrollview');
var HomeView = require('views/HomeView');
var DescriptionView = require('views/DescriptionView');
var paginationView = new Scrollview({
direction: Utility.Direction.X
});
var AppViews = [
HomeView,
DescriptionView
];
paginationView.sequenceFrom(AppViews);
module.exports = paginationView;
});
这是模块代码
define(function(require, exports, module) {
var View = require('famous/core/View');
var Surface = require('famous/core/Surface');
var FlexScrollView = require('famous-flex/FlexScrollView');
var MainView = require('views/MainView');
var EventHandler = require('famous/core/EventHandler');
function HomeView() {
View.apply(this, arguments);
}
HomeView.prototype = Object.create(View.prototype);
HomeView.prototype.constructor = HomeView;
HomeView.DEFAULT_OPTIONS = {};
var homeView = new HomeView();
var scrollView = new FlexScrollView();
homeView.add(scrollView);
for (var i = 0, temp; i < 40; i++) {
var surface = new Surface({
content: "Surface: " + (i + 1),
size: [undefined, 200],
properties: {
backgroundColor: "hsl(" + (i * 360 / 40) + ", 100%, 50%)",
lineHeight: "200px",
textAlign: "center"
}
});
surface.pipe(scrollView);
// ... I want to pipe to the parent scrollview here ...
如何将表面从第二个模块传送到第一个模块中的滚动视图?我仍在学习整个事件管道,不确定我将如何在这里实施它。我知道,由于我是从著名的 View 模块继承的,所以我应该能够访问一些高级事件管理,但对于我的情况如何做我一无所知。
模块 HomeView
扩展了 Famo.us View
,因此您可以将表面通过管道传递给 HomeView
// ... I want to pipe to the parent scrollview here ...
Surface.pipe(this._eventOutput);