Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use touch events without importing a whole mobile-driven JavaScript framework?

I'm working on a responsive design on which I'd like to use two specific touch events, tap and swipe. Is it possible to import a single jQuery Mobile slice (i.e. jquery.mobile.events.js) or a piece of any other mobile-driven JavaScript framework, without importing the entire set of assets? I'm currently using jQuery, just so you know.

like image 292
João Avatar asked Dec 27 '11 16:12

João


People also ask

Does touchstart work on desktop?

The touchstart event occurs when the user touches an element. Note: The touchstart event will only work on devices with a touch screen.

Does Click work on mobile?

On a phone, mouse click doesn't exist. Instead, there are only touch events. This isn't entirely true, because some devices on some browsers for some elements will simulate a mouse click when a touch is made.

What is the use of Touch_move?

The touchmove event is used to execute a script when the user moves the finger across the screen. It works only on touch screen devices and triggers once for every movement and continues to trigger until the finger is released.


1 Answers

You can also just download the module Events.Touch from jQuery Mobile using their download builder http://jquerymobile.com/download-builder/

Just tick the option 'Touch', add the JavaScript file to your project so you can start listening to events such as:

  • touchstart
  • touchmove
  • touchend
  • tap
  • taphold
  • swipe
  • swipeleft
  • swiperight
  • scrollstart
  • scrollstop

ps: You must be using the jQuery library as jQuery mobile runs on top of it.

like image 156
ThiagoPXP Avatar answered Sep 22 '22 07:09

ThiagoPXP