I have image tiles on my website, for want of a better description.
On mobile, I would like a single tap on one of these tiles to bring up some more text (describing the content of that section), before a second tap actually navigates to that link and opens the new page.
At the same time, on desktop I would like a hover of the mouse to reveal the hidden text, before a click navigates to that section.
I had thought I could simply use hover - having read before that a single tap on touch based devices imitates hover, before a second tap opens the link. However, this doesn't appear to be the case for me - if I use hover, E.G:
<a class="tileLink" href="/projects/london-serviced-apartments">
<section class="tile">
<img src="/images/lsa-s.jpg" srcset="/images/lsa-m.jpg 600w, /images/lsa-l.jpg 1000w, /images/lsa-xl.jpg 1920w" alt="services" />
<h1>London Serviced Apartments</h1>
<p class="hidden">Test hover text</p>
</section>
</a>
.tileLink:hover .tile{
opacity: 0.75;
}
.tileLink:hover p{
display: inline;
}
when I tap once on one of the tiles, the hidden text displays briefly but then the link is immediately navigated to - so the user is taken directly to that section before having had a chance to read the text and decide if they want to open the link or not.
I did try doing this using Javascript:
$(".tileLink").click(function(e){
if( $(this).find(".tile").hasClass("tapped") ){
}else{
e.preventDefault();
$(this).find(".tile").addClass("tapped").find("p").removeClass("hidden");
}
});
which actually works fine for mobile, but then on desktop hover doesn't work - a click is needed to display the hidden text, and a second click is needed to navigate to that section.
Is there a simple way of doing this that will work across multiple devices?
is not shown on desktop on mouseover? Because that would be a different issue, your `.tileLink:hover p` might not have authority over your `.hidden`, could you post that as well?
– swornabsent Sep 04 '15 at 14:41