简体   繁体   English

在通过AJAX加载内容后,iPad会触发对元素的悬停效果

[英]iPad triggers hover effect on element after content load via AJAX

I got a very strange behaviour of my web page on iPads (only). 我在iPad上的网页上有一个非常奇怪的行为(仅限)。 My web application is based on AJAX loading. 我的Web应用程序基于AJAX加载。 So some parts of the page, like filters and the main wireframe, are static but the main content that gets calculated is being loaded via AJAX. 因此,页面的某些部分(如过滤器和主线框)是静态的,但计算的主要内容是通过AJAX加载的。

Within the content the filter options, which a user has checked, are represented by div-elements (filter chips) as it is in other pages like ebay or wherever. 在内容中,用户已经检查过的过滤器选项由div元素(过滤器芯片)表示,就像在ebay或其他任何页面中一样。 The user is able to uncheck the filters by X-ing such a chip or just click the filter-checkbox on the static content. 用户可以通过X-ing这样的芯片取消选中过滤器,或者只需单击静态内容上的filter-checkbox。 Also there is a link after the chips in order to reset/delete all filter options at a time. 芯片之后还有一个链接,以便一次重置/删除所有过滤器选项。

Under the filter chips sections, there is another section for sorting the result set on the page. 在过滤器芯片部分下,还有另一个部分用于对页面上的结果集进行排序。 It is represented as a bar/beam that occupies the full width. 它表示为占据整个宽度的条/梁。

It looks like the following: 它看起来如下:

-------------------------------------------- | filter1 filter2 filter3 reset_all_filters | <--- FilterChips section |-------------------------------------------- | sortByA | sortByB | sortByC | sortByD | <--- Sorting section --------------------------------------------

A click on the reset_all_filters link causes the content to be reloaded. 单击reset_all_filters链接会导致重新加载内容。 After the load the user won't see the FilterChips section after resetting them and the whole content moves up. 加载后,用户在重置后会看不到FilterChips部分,整个内容都会向上移动。 So the Sorting section is now exactly on the position where the FilterChips section previously was. 因此,排序部分现在正好位于FilterChips部分之前的位置。

The funny thing about this is, that the sorting item right below the clicked reset_all_filters-link gets a hover effect after the content has been loaded. 有趣的是,在点击的reset_all_filters-link正下方的排序项目在加载内容后获得悬停效果。

I assume that the tap pointer still remains on that position and causes the element underneath being hovered. 我假设点击指针仍然保持在该位置并导致下面的元素悬停。

For those who wonder why the FilterChips section or Sorting section belongs to the loaded content: This is indeed a thing I/we (company) must reconsider. 对于那些想知道为什么FilterChips部分或Sorting部分属于加载内容的人:这确实是我/我们(公司)必须重新考虑的事情。 But in the meantime, we have to deal with it. 但与此同时,我们必须处理它。

So are there any suggestions regarding my problem? 关于我的问题有什么建议吗? Every help is appreciated! 感谢每一位帮助!

In an older question from Jan'13 someone stated in the Apple's documentation this is described as an intended behaviour. 在2013年1月的一个较旧的问题中,有人在Apple的文档中说过,这被描述为预期的行为。

https://stackoverflow.com/a/48217487/1503923 https://stackoverflow.com/a/48217487/1503923

Here the quote: 这里引用:

This seems to be intended behaviour in Safari. 这似乎是Safari中的预期行为。 Apple's documentation says that single-finger taps are handled as mouse events, and shows which events are raised during a tap. Apple的文档称单指点击是作为鼠标事件处理的,并显示在点按期间引发的事件。 There's a mouseover at the start of the tap, but a mouseout is only triggered when you click on something else. 在点击开始时有一个鼠标悬停,但只有当您点击其他内容时才会触发鼠标输出。 This implies that Safari assumes that the pointer stays in the same place until the next tap, which would mean it makes sense for the lower element to be in the hover state. 这意味着Safari假定指针停留在同一个位置,直到下一次点击,这意味着下部元素处于悬停状态是有意义的。


To solve your problem you would have to apply some kind of media query in your css or a special css rule which will avoid having a different kind of styling for your :hover element. 要解决您的问题,您必须在您的css或特殊的CSS规则中应用某种媒体查询,这将避免为您的:hover元素设置不同类型的样式。

a:hover { background-color: blue; }

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)  {
    a:hover { background-color: transparent; }
}

Or some kind of other treatment to determine if your user has an ipad or any other tablet device where this problem might occur. 或某些其他处理,以确定您的用户是否有可能发生此问题的ipad或任何其他平板电脑设备。

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

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