Famo.us GenericSync blocked by 'mousedown' event

Famo.us GenericSync blocked by 'mousedown' event

本文关键字:mousedown event by us GenericSync blocked Famo      更新时间:2023-09-26

我注意到Famo.us中的GenericSync类有一些奇怪的行为。如果你在表面上添加"mousedown"事件,它只会阻塞引擎上的GenericSync。只需注释掉最后一行,就可以看到问题所在。

http://jsfiddle.net/ckhu1pvw/8/

define('main', function (require, exports, module) {
    var Engine = require('famous/core/Engine');
    var EventHandler = require('famous/core/EventHandler');
    var Surface = require('famous/core/Surface');    
    var mainContext = Engine.createContext();    
    var surface = new Surface({
        size: [400, 200],
        content: "Drag on me",
        properties: {
            background: "red",
            lineHeight: "200px",
            textAlign: "center",
            color: "white"
        }
    });    
    var eventHandler = new EventHandler();
    surface.pipe(eventHandler);  
    mainContext.add(surface);    
    var GenericSync = require("famous/inputs/GenericSync");
    var MouseSync = require("famous/inputs/MouseSync");
    var TouchSync = require("famous/inputs/TouchSync");
    var ScrollSync = require("famous/inputs/ScrollSync");    
    GenericSync.register({
        mouse: MouseSync,
        touch: TouchSync,
        scroll: ScrollSync
    });
    var sync = new GenericSync();    
    sync.addSync(["mouse", "touch", "scroll"]);
    sync.on("start", function (event) {
        console.log("SyncStart");
    });    
    sync.on("update", function (event) {
        surface.setContent(event.delta[0] + ", " + event.delta[1]);
    });    
    sync.on("end", function (event) {
        console.log("SyncEnd");
        surface.setContent("0, 0");
    });   
    Engine.pipe(sync);    
    // comment out this line to see the sync fail :(
    //surface.on('mousedown', function(e) {console.log('The down of the mice');});
});

这是一个更大的计划的最后一个谜题,所以如果你有一个看,请尽量保持一个类似的结构(我的意思是请使用同步引擎)。任何肮脏的hack都是受欢迎的,我只是对优雅的解决方案失去了希望。

谢谢,戴夫

update by David Szucs on 11.08.2014

我该怎么做才能在表面上捕获mousedown事件并在全局同步上触发start事件?

我认为这就像在你点击的项目的zIndex上面放一些东西。如果你通过表面进行同步,它又能工作了。不确定它是否有帮助也许如果我对你在做什么有更多的了解,我可以进一步帮助。