3

I noticed some weird behaviour on the GenericSync class in Famo.us. If you add "mousedown" event on a surface it just blocks GenericSync on the Engine. Just comment out the last line in the Fiddle to see the problem.

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');});
});

This is the last puzzle of a greater plan, so if you have a look please try to keep a similar structure (I mean please use sync on Engine). Any dirty hack is welcomed, I just lost hope in an elegant solution.

Thanks, Dave

update by David Szucs on 11.08.2014

What can I do to catch mousedown event on the surface as well as trigger start event on the global sync?

  • Hi David & welcome to SO. Best to phrase your question as a question so it can be answered, rather than just an observation. – Rory Aug 09 '14 at 18:46
  • Okay, sorry for missing question. I need consistent mouse sync but `mousedown` event blocks it on surfaces. Can I emit `mousedown` event on the global sync? Or may pipe in that surface so it fires the event the sync class as well, so it could catch and trigger `start` event? Thanks for review this matter so quickly... – David Szucs Aug 11 '14 at 13:02

1 Answers1

1

I would think of it like putting something in the zIndex above the item your clicking. If you pipe the sync through the surface it works again. Not sure if it helps maybe If I had a little more understanding of what you where doing with this I could help further.

aintnorest
  • 1,326
  • 2
  • 13
  • 20
  • I think I wasn't clear enough... first question, sorry about it. :) The goal is to catch the `mousedown` event on the surface as well as trigger sync `start` event. Any ideas? – David Szucs Aug 11 '14 at 13:07
  • 1
    adding surface.pipe(sync); right after the engine sync Made the fiddle you put up write to console on both events. – aintnorest Aug 11 '14 at 15:46
  • Last piece of puzzle is in! Thanks a lot for the perfect answer, I overcomplicated a bit I think. – David Szucs Aug 11 '14 at 16:47