1

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?

Kristonitas
  • 201
  • 1
  • 10
  • Made a bug report to Apple, will post results here. – Kristonitas Apr 20 '18 at 16:58
  • 1
    WebKit has [implemented a fix](https://bugs.webkit.org/show_bug.cgi?id=185040), but indicates that the negative timestamp comes from UIKit. I haven't found any fix from UIKit, or a bug having been reported there. No word on when Safari will implement the version of WebKit with this fix. – Lucas Fowler May 03 '18 at 14:46

0 Answers0