流星中的触摸事件 [英] Touch events in Meteor
问题描述
我开始使用Meteor做的第一件事是开始为移动/平板电脑编写基于触摸的Web应用程序.重现问题的方法如下:
The first thing I started to do with Meteor was start writing a touch-based web application for mobile/tablets. Here's how you reproduce the problem:
第一步:创建一个空白项目
First step: create a blank project
meteor create touch_example
cd touch_example
meteor
第二,将这些内容添加到.js文件中.这第一位为触摸设备发出警报,因为它们没有控制台.
Second, add these things to the .js file This first bit spits out an alert for touch devices and because they have no console.
Meteor.log = function(input){
if (typeof console !== 'undefined' && typeof Touch !== "object")
console.log(input);
else
alert(input);
}
这是罪魁祸首.
Template.touchbox.events = {
'touchmove' : function (e){
e.preventDefault();
Meteor.log('touchy');
}
};
最后一步,更改模板,以便页面上至少有一个"touchbox" div.从理论上讲,它应该承担事件.您会注意到,如果将"touchmove"更改为"click",则效果很好.如果将其更改为dblclick
,它也可以正常工作.触摸事件无济于事.
Last step, change the template around so there's at least one "touchbox" div on the page. IN theory, it should be taking the events. You'll notice that if you change 'touchmove' to 'click' that it works just fine. If you change it to dblclick
it will also work fine. Touch events don't do anything.
推荐答案
像jQuery一样,标准不能处理这些问题,请尝试使用jquery-mobile:
Looks like jQuery as standard doesn't handle these, try using jquery-mobile: http://jquerymobile.com/demos/1.1.0/docs/api/events.html
要将其添加为软件包,您可能需要在这里查看我的其他答案: jQuery-Mobile Meteor样本集成和/或集成准则
To add it as a package you might want to look at my other answer here: jQuery-Mobile Meteor sample integration and/or integration guidelines
我发现了关于绑定触摸的其他帮助与鼠标事件相同,但是它使用了绑定,并且我怀疑是否会与实时用户界面流星相关联: http://xavi.co/articles/trouble-with-touch-events- jQuery
I found some other help regarding binding touches the same as mouse events however this uses bind and I doubt that will hook up with the live-ui meteor stuff: http://xavi.co/articles/trouble-with-touch-events-jquery
这篇关于流星中的触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!