如何使用famo.us拖动鼠标拖动滚动视图?

时间:2014-06-15 11:42:15

标签: famo.us

我希望能够在桌面计算机上使用常规鼠标拖动滚动滚动视图。不幸的是,目前scrollView只会移动鼠标滚动和触摸手势。如何使用常规鼠标拖动使其工作,即单击拖动然后释放?

2 个答案:

答案 0 :(得分:4)

您可以使用MouseSync类来实现此目的。 scrollview使用的GenericSync仅使用TouchSync和ScrollSync。如果您创建自己的MouseSync类,则可以将曲面传递给mouseSync和scrollview,然后将mouseSync传递给scrollview。这是一个例子。祝你好运!

var Engine      = require('famous/core/Engine');
var Surface     = require('famous/core/Surface');
var Scrollview  = require('famous/views/Scrollview');
var MouseSync   = require('famous/inputs/MouseSync');

var context = Engine.createContext();

var surfaces = [];

var scrollview = new Scrollview();

scrollview.sequenceFrom(surfaces);

var mouseSync = new MouseSync({direction:1});

for (var i = 0; i < 10; i++) {
  var surface = new Surface({
    size:[undefined,200],
    properties:{
      backgroundColor:'hsl('+(i*360/30)+',100%,50%)'
    }
  });

  surfaces.push(surface);

  surface.pipe(mouseSync);
  surface.pipe(scrollview);

};

mouseSync.pipe(scrollview);
context.add(scrollview);

答案 1 :(得分:0)

或者,您可以使用支持开箱即用的鼠标事件的FlexScrollView:

var scrollView = new FlexScrollView({
  mouseMove: true
});

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