On Safari for MacOs this simple code part isnt working for me at all.
e instanceof TouchEvent
- it seems that for some reason the "TouchEvent" is not fully supported by Safari for MacOs. It does work on Safari for iOs which is even stranger imo.
ReferenceError: Could not find "TouchEvent" variable.
Is there a proper solution for solving this issue?
On Safari for MacOs this simple code part isnt working for me at all.
e instanceof TouchEvent
- it seems that for some reason the "TouchEvent" is not fully supported by Safari for MacOs. It does work on Safari for iOs which is even stranger imo.
ReferenceError: Could not find "TouchEvent" variable.
Is there a proper solution for solving this issue?
So i came over this post where i finally found the working solution for me. I think everyone should know this little trick as it can save costs and lots of time. The classic, well-known Apple issues - year after year ...
https://blog.cotten.io/desktop-safari-still-hates-instanceof-touchevent-1fcdda8409d5
The trick is to use: const isTouch = ("touches" in e);
instead of const isTouch = e instanceof e;
Which is strange but i think we have to deal with it :D
typeof TouchEvent !== "undefined" && e instanceof TouchEvent
should probably "work." – C3roe Commented Jan 30 at 13:13