This is more of a conceptual question. After reading about Jquery Mobile, it got me thinking about how one would implement touch events like “tap” or “rub” using plain javascript. Since Jquery Mobile is built on javascript, does that mean the Jquery team is able to add custom events to vanilla javascript like ontap or ondrag?
This sums up my thought process:
- Jquery is built on base functionality of vanilla Javascript
- base functionality of vanilla Javascript does not support touch events; therefore, Jquery does not support touch events
- conclusion: in order for Jquery to support touch events, vanilla Javascript must incorporate touch events?
Some mobile browsers are able to fire events related to the interaction with a touch screen. Mobile Safari (don’t know about other mobile browser but things shouldn’t change much) for example has some custom events like
touchstart,touchmoveortouchendhttp://developer.apple.com/library/IOs/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
That’s how jQuery mobile and other libraries are able to handle this kind of events.
If you want to dig deeper into a simple “real-world” implementation of one of this event you can have a look at the source code of this library, which handles the ‘swipe’ event.
https://github.com/cubiq/SwipeView/blob/master/src/swipeview.js