简体   繁体   English

在Android浏览器中模拟触摸事件的悬停行为

[英]Simulating hover behaviour in Android browser for touch events

My Wordpress website is using Superfish 1.5.4 to render menu items. 我的Wordpress网站使用Superfish 1.5.4渲染菜单项。

My menu consists of a number of parent menu items, which are also clickable pages, and on hovering over these parent items, the sub menu items should appear 我的菜单由许多父菜单项组成,这些菜单项也是可单击的页面,将鼠标悬停在这些父项上时,应显示子菜单项

When hovering over a parent menu item in my PC's browser the sub menu items appear, and this is the intended behaviour. 将鼠标悬停在PC浏览器中的父菜单项上时,将显示子菜单项,这是预期的行为。

In iPhone browsers, when touching a parent menu item, the sub menu items appear, and this too is the preferred behaviour. 在iPhone浏览器中,当触摸父菜单项时,会出现子菜单项,这也是首选的行为。 (So this effectively triggers the hover behaviour) (因此,这有效地触发了悬停行为)

The problem is that on Android devices, touching a parent menu item causes a click event as opposed to the hover behaviour we see for iPhone. 问题在于,在Android设备上,触摸父菜单项会导致点击事件,这与我们在iPhone上看到的悬停行为相反。

I've looked at the Superfish JavaScript and I don't see any iPhone specific logic. 我看过Superfish JavaScript,但没有看到任何iPhone特定的逻辑。

Therefore, I'm wondering why a touch in an iPhone causes the hover behaviour, but not in an Android device. 因此,我想知道为什么iPhone中的触摸会导致悬停行为,而Android设备中却没有。

What am I missing here? 我在这里想念什么?

The problem is essentially that a :hover feature doesn't really exist on touch devices (given that there's no physical way to hover like you can with a mouse). 问题本质上是:hover功能实际上在触摸设备上并不存在(假设没有像鼠标一样可以物理地悬停的方式)。 The only reason you get the intended effect on an iPhone is that devices using iOS trigger the :hover event before the click event so you will see the intended style for a brief moment before the page changes. 在iPhone上获得预期效果的唯一原因是使用iOS的设备在click事件之前触发了:hover事件,因此您会在页面更改前的一会儿看到预期的样式。 There aren't really any good solutions to this, especially for menus with sub-menus like yours, but I'd check out some resources like this to get a better idea of the problem and possible ways it's being "solved". 确实没有很好的解决方案,尤其是对于像您这样的具有子菜单的菜单,但我会检查一些此类资源,以便更好地了解问题以及“解决”的可能方法。

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

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