In iOS Safari, the first click event may not work when a DOM change occurs
#122
Closed
shinsenter
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue
Issue #121:
In iOS Safari, the first
clickevent may not work when usingDefer.all()with thewaitForUserActionargument set totrueand one of deferred scripts make any DOM change.Bug Detail
When a
waitForUserActionor theDefer.lazyoption is set totrue, Defer.js attaches atouchstartevent on thewindowelement to track user interaction and execute lazied script tags.Let's suppose the user touches a link in mobile browser. Because the user has the ability to double tap to zoom or scroll, whenever the user touches the screen, the browser does not instantaneously know whether the user meant to click the link, or is double tapping. Therefore every mobile browser adds a 300ms delay onto tap interactions to see if the user taps again.
Touch gestures handled by Safari on iOS emulate mouse events. When you touch an iPhone’s screen, in principle Safari responds by firing an entire event cascade:
But during the touch event cascade, Safari iOS stops firing
clickevents when a DOM change takes place.Apple's Figure 6-4: One-finger gesture emulating a mouse
Source: Safari Web Content Guide
Temporary solutions
Add a pause at least 300ms to the
Defer.all(). For example:Defer.all('script[type="your-type"]', 500, true);.Beta Was this translation helpful? Give feedback.
All reactions