Reputation: 1632
I can check if mousedown
has been triggered like so:
$(something).on("mousemove touchmove", function(e) {
if (e.buttons == 1){
// mouse is down
}
})
Very simple question, how can I check if touchstart
has been triggered in the above? I tried:
if (e.type === 'touchstart'){
// touchstart has been triggered
}
This did now work at all. Can someone please provide direction as to how I can achieve this?
Upvotes: 2
Views: 1171
Reputation: 337530
Your if
statement checking the e.type
property is the correct logic to use. Your condition fails though, because you hook to mousemove
and touchmove
, not touchstart
.
You need to either include touchstart
in the event list:
$(something).on("mousemove touchmove touchstart", fn);
Or check the type
property for touchmove
, if that was your intent:
if (e.type === 'touchmove'){
// touchmove has been triggered
}
Upvotes: 1