Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Have a single tap trigger a hover in iOS and another release the hover?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #152854
    Alex
    Participant

    Hey all,

    So I have a ul that does something like this:

    http://jsfiddle.net/L4cmV/

    (It’s sloppy, the final is cleaner)

    and in iOS you have to hold your finger on the div in order to reveal, which makes it difficult to click one of the 2 links.

    I seem to be stuck on how I can make this trigger on tap – stay open until you tap it again, or tap one of the 2 links…

    Any help would be greatly appreciated.

    Thanks.

    #152857
    Martin Duran
    Participant

    You can do this with CSS:

    http://codepen.io/Martin-Duran/pen/qtpJF

    This should also work in mobile browsers, including iOS.

    #152858
    Senff
    Participant

    This should also work in mobile browsers, including iOS.

    It doesn’t, because iOS only detects hovers on <A> tags, not <DIV>s.

    But even if you would change the divs to an A, and have something like this: http://codepen.io/senff/pen/qwjhC, then the problem remains that the “un-hover” doesn’t work on iOS. Been struggling with it myself for quite a while.

    #152874
    Martin Duran
    Participant

    Senff is right, there would be no way to get the div to close. What you could do is include a close button, styled as you please, at a breakpoint that would only target small devices. Then, attach some jQuery to that button the would close the div on click (touch).

    #153097
    Alex
    Participant

    I ended up doing this and it worked great…

                    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
    
                    $(".th-painting").click(function(){  // Update class to point at the head of the list
    
                    });
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.