Famo.us GenericSync blocked by 'mousedown' event
Famo.us GenericSync blocked by 'mousedown' event
我注意到Famo.us中的GenericSync类有一些奇怪的行为。如果你在表面上添加"mousedown"
事件,它只会阻塞引擎上的GenericSync。只需注释掉最后一行,就可以看到问题所在。
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上面放一些东西。如果你通过表面进行同步,它又能工作了。不确定它是否有帮助也许如果我对你在做什么有更多的了解,我可以进一步帮助。
相关文章:
- issue with FB.Event.subscribe
- Angularjs :$routeChangeStart event
- event.prventDefault()持续多久
- <text区域>在我的html中包含event.keycode==13之后,wrap就不起作用了
- KeyDown event for CKeditor
- Javascript events: window.event vs argument reference (funct
- 动态填充Bootstrap选择选择器:change event dos'不起作用
- <td> focusin event .addclass
- 使用谷歌图表将mousedown事件注册为click
- event.preventDefault阻止ajax调用
- google.maps.event.addDomListener(window, 'load', fun
- 如何知道鼠标按钮的当前状态(mouseup状态或mousedown状态)
- jQuery event.target is_a_child_of(element)
- event.stopPropagation()在firefox javascript中不起作用
- asp.net text onkeyup event
- 如何从ondragend获取正确的event.pageX
- 面料:“;鼠标:向下”;在event.target中未返回对象
- 使用event.target.classlist区分按钮颜色
- event.keycode vs event.which
- Famo.us GenericSync blocked by 'mousedown' event