-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cordova app (iOS) returning from background has incorrect timestamp for touch events #19
Comments
This time delta only occurs for touch events? The following click event has a correct timestamp? It sounds like a bug indeed, when it's only for touch events. In that case, we could use |
Yeah you get a delta of like 2 minutes between the touch and the click! |
OK, weird. I'll try to confirm your issue later in a |
We've only tried it in UIWebView. We're not the only ones who've noticed the problem: http://stackoverflow.com/questions/26177087/ios-8-mobile-safari-wrong-timestamp-on-touch-events It's a crazy bug! |
This is a bad fix imo, because the problem lies more in the discrepancies between the React Native events and the W3C events. But at least it allows us to use the responder plugin… Also note that using event.timeStamp can be problematic on iOS 8 webview, as seen here: zilverline#19
It is not consistent across browsers. Fixes #19.
This is not the fault of this library, but seemingly a bug in UIWebView, but I thought it would be worth recording here (and possibly implementing a workaround in the plugin) to save someone else 2 days of their life.
In short, when a Cordova app returns from some particular background state in iOS, the timestamps on touch events are offset by the amount of time the app has been in the background. This means that the cancelling of mouse events doesn't work, because the time delta between last touch and current mouse event is like 3 minutes, instead of 300ms!
We figured out a workaround, which is to use
Date.now()
instead ofnativeEvent.timeStamp
when recording thelastTouchEvent
time.I've a few ideas about how this could be incorporated into this plugin:
Date.now()
when recording the last touch timestamptimeStampResolver
as a function, and have a different version of the injector that passes inDate.now
as the resolver for use in Cordova apps.TapEventPlugin
can be monkey-patched on an app-by-app basis.Thoughts @s0meone?
The text was updated successfully, but these errors were encountered: