Why mobile Safari touchEvents have negative timestamp?

喜你入骨 提交于 2020-01-05 09:06:24

问题


I use timestamps to accurately detect long press by comparing event timestamps with the requestAnimationFrame passed timestamp. By documentation both of these timestamps should be:

This value is the number of milliseconds elapsed from the beginning of the current document's lifetime till the event was created.

https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp

I've created a jsFiddle, if I click with a mouse on a desktop, it shows positive numbers. If I open on an iPhone 7+, it looks like there is about 40 minutes subtracted from the event's timeStamp value.

https://jsfiddle.net/2r0nzcmu/1/

window.addEventListener("touchstart", function (event) {
  let text = document.querySelector("#text");
  text.textContent = event.timeStamp;
})

Is this an actual bug? (and if you know a better way) How should I better detect long press?

来源:https://stackoverflow.com/questions/49920582/why-mobile-safari-touchevents-have-negative-timestamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!