iPad / iPhone双击问题 [英] iPad/iPhone double click problem

查看:131
本文介绍了iPad / iPhone双击问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题与 iPad / iPhone悬停问题会导致用户双击链接,点击链接的用户必须点击两次才能真正转到该链接。

我在这个问题中实现了解决方案,但现在我遇到了一个新问题。重定向发生在用户点击链接时,但不管发生什么情况都会发生。因此,即使用户试图滚动页面,并且他们在链接上开始滚动,页面也会在放开滚动时重定向。



有没有办法让链接保持只需要一次点击,但是如果它们滚动,不要重定向页面?

解决方案

这就是我最终做的事情: 了解触摸事件,而不是滚动事件,所以他们只对开始触摸和结束触摸做出反应。我们要做的是区分滚动和不滚动。这是我做的:

  $('a')
.live('touchstart',function(){
isScrolling = false;
})
.live('touchmove',function(e){
isScrolling = true;
})
.live ('touchend',function(e){
if(!isScrolling)
{
window.location = $(this).attr('href');
}
});

这是按顺序执行的:


  1. 触摸第一次录制时,将isScrolling设置为false。
  2. 移动touch时,将isScrolling设置为true。如果触摸无法移动,则不会发生这种情况。

  3. 触摸停止后,如果没有发生滚动,请将页面重定向到链接的href。

编辑:在此之后,我发现问题是由SuperFish造成的。在页面宽度不足的情况下禁用superfish解决了问题。


I'm having a very similar problem to iPad/iPhone hover problem causes the user to double click a link where a user tapping a link has to tap twice to actually go to it.

I implemented the solution in that question, but I have a new problem now. The redirection happens when the user taps a link, but it happens no matter what. So even if the user is trying to scroll the page, and they start the scroll on a link, the page redirects when they let go of the scroll.

Is there a way to keep the links so that they only need one tap, but if they're scrolling, don't redirect the page?

解决方案

Here's what I ended up doing:

The problem is that touchstart and touchend only know about touch events, not scroll events, so they only react to starting the touch and ending the touch. What we have to do is distinguish between scrolling and not scrolling. Here's what I did:

$('a')
    .live('touchstart', function(){
        isScrolling = false;
    })
    .live('touchmove', function(e){
        isScrolling = true;
    })
    .live('touchend', function(e){
        if( !isScrolling )
        {
            window.location = $(this).attr('href');
        }
    });

This does these things in order:

  1. When touch is first recorded, set isScrolling to false.
  2. When touch is moved, set isScrolling to true. This will not happen if the touch doesn't move.
  3. When touch is stopped, if scrolling has not happened, redirect the page to the link's href.

Edit: A while after this, I discovered the problem was being caused by SuperFish. Disabling superfish when the page was under a certain width solved the problem.

这篇关于iPad / iPhone双击问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆