开发者

Enable quicks (double?) clicks on Ipad Safari

开发者 https://www.devze.com 2023-03-03 04:33 出处:网络
I\'m building a HTML/JavaScript interface in which I would need some reactivity and so, the possibility for users 开发者_开发知识库to click really fast on the same button on the page.

I'm building a HTML/JavaScript interface in which I would need some reactivity and so, the possibility for users 开发者_开发知识库to click really fast on the same button on the page.

I disabled the doubleclick/zoom on the iPad thanks to the <meta name="viewport" content="user-scalable=no" />, but then, if I double click or click too fast on the buttons, it does nothing.

I'm using jQuery and tried the dblclick event, didn't work.


You can try using the doubletap plugin which enable the use of "doubletap" events on iPhone and iPad devices.


I gave up on this, rolled my own inside my 'touchstart - move - touchend' sequence. Its horrible, but, inside my touchend, I have :

if (swipeMoving==0) {
swipeStarted = 0;
tapco +=1;
if (tapco==2) doDblClick();
window.setTimeout(function(){ tapco=0; }, 700);
return;
}

If you want click, too, put it in a delay, and cancel if the second click comes.


Use this script to use double click in Ipad. http://code.google.com/p/jquery-ui-for-ipad-and-iphone/

Alternative :-

As click on the desktop browser is equivalent to the touch on the Ipad. So, the double click will be equivalent to the click on the Ipad.

To implement this :

if((navigator.userAgent.match(/iPad/i))){
    $(".element").click(function () {/*run the code*/ });
}
else {
    $(".element").dblclick(function () {/*run the code*/ });
}

Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消