touchmove中的JavaScript DOM更改延迟,直到滚动在移动Safari上结束 [英] JavaScript DOM changes in touchmove delayed until scroll ends on mobile Safari

查看:428
本文介绍了touchmove中的JavaScript DOM更改延迟,直到滚动在移动Safari上结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在移动版Safari中,在处理元素的 touchmove 的过程中,我更改了该元素的 className 。不幸的是,当用户滚动时,或直到惯性滚动的最后,视觉变化不会发生。

In mobile safari, in the course of handling touchmove for an element, I change the className of that element. Unfortunately, the visual change does not occur while the user is scrolling, or until the very end of an inertial scroll.

我该怎么做才能获得 className 立即直观地获取?

What can I do to get the className to visually take immediately?

更多:显然这不仅限于className更改,看似对DOM的任何更改,例如 innerHTML 样式

More: Apparently this isn't limited to className changes, but seemingly any change to the DOM, such as innerHTML and style.

推荐答案

这很遗憾。 iOS Safari会将所有DOM操作排队,直到滚动或手势结束。有效地,DOM在滚动期间被冻结。

This is by design unfortunately. iOS safari will queue up all DOM manipulation until the end of a scroll or gesture. Effectively the DOM is frozen during a scroll.

我以为我可以在苹果开发者页面上找到对此的引用,但我只能找到这个指向jQueryMobile的链接:< a href =http://jquerymobile.com/test/docs/api/events.html> http://jquerymobile.com/test/docs/api/events.html 。

I thought I could find a reference to this on an apple developer page, but I can only find this link to jQueryMobile: http://jquerymobile.com/test/docs/api/events.html.


请注意,iOS设备在滚动期间冻结DOM操作,排队
它们在滚动完成时应用。我们目前正在调查
方法,允许在滚动开始之前应用DOM操作

Note that iOS devices freeze DOM manipulation during scroll, queuing them to apply when the scroll finishes. We're currently investigating ways to allow DOM manipulations to apply before a scroll starts

希望这有帮助!

这篇关于touchmove中的JavaScript DOM更改延迟,直到滚动在移动Safari上结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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