简体   繁体   English

PhoneGap上触摸事件的行为不一致

[英]Inconsistent Behavior for Touch Events on PhoneGap

I searched for weeks for a slide plugin that would work on a Phonegap app using knockout, bootstrap and jQuery. 我搜索了数周的幻灯片插件,该插件可使用敲除,引导程序和jQuery在Phonegap应用程序上运行。 Unfortunately, nothing was fitting my needs. 不幸的是,没有什么适合我的需求。 So, I built a custom slider. 因此,我建立了一个自定义滑块。 It seems to be working (I'm currently testing it on Android 2.3.4 - I'm starting with the lowest version we plan to support), but it doesn't always respond. 它似乎正在运行(我目前正在Android 2.3.4上对其进行测试-我从我们计划支持的最低版本入手),但它并不总是能够响应。 The touchstart event seems to be rather sensitive. touchstart事件似乎非常敏感。 Does anyone have any ideas on how I can make the user experience more consistent and reactive to the touchstart event? 是否有人对我如何使用户体验更一致和对touchstart事件有反应有任何想法? I have researched on this for a few days, and it seems others have similar issues, but nothing exactly like mine. 我对此进行了几天的研究,似乎其他人也有类似的问题,但与我的完全不同。 And none of the issues seem to have a definitive answer. 而且这些问题似乎都没有明确的答案。 Does Phonegap have issues with touch events? Phonegap的触摸事件是否有问题?

Here is my knockout function: 这是我的淘汰赛功能:

 performSlide: function() {
       $('#sliderDiv').on({ 'touchstart' : function() {
        $('div.slideArrow').animate({
        left: "+=200"
            }, 1000, function() {
                shell.navigate('home', 'slide');
            });
             }
    });
    }

I'm using the event binder on a div to call the function. 我在div上使用事件绑定程序来调用该函数。

<div class="linkHeader" id="sliderDiv" data-bind="event: { touchstart: performSlide }">

I have also ensured that the z-index of my div is set higher than the other elements. 我还确保将div的z-index设置为高于其他元素。 The position attribute is also set to relative. position属性也设置为相对。

Any advice offered would be much appreciated. 提供的任何建议将不胜感激。 I would love if this performed a little better... ok, a lot better. 我希望它能表现得更好一点...好吧,好得多。 :-) :-)

I have not received an answer, but I ended up figuring out what I needed to change. 我还没有收到答案,但是最后我弄清楚了我需要更改的内容。 First, I needed to detect my event and capture it in a variable. 首先,我需要检测我的事件并将其捕获到变量中。 Then, I also changed the databinding and .on function to detect the touchmove instead of the touchstart. 然后,我还更改了数据绑定和.on函数以检测touchmove而不是touchstart。 It is working much better now. 现在它的工作要好得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM