How to use touch events without importing the entire JavaScript platform for mobile devices?

I am working on a flexible design in which I would like to use two special touch events, tap and swipe . Is it possible to import one piece of jQuery Mobile (i.e. jquery.mobile.events.js ) or a part of any other JavaScript platform with support for mobile devices without importing the entire set of assets? I am currently using jQuery, so you know.

+7
source share
3 answers

I found a solution for my problem: TouchSwipe , a jQuery plugin for touch devices that handles swipe events. Like a boss!

0
source

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

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

  • touchstart
  • Touchmove
  • touchend
  • click
  • taphold
  • napkins
  • swipeleft
  • swiperight
  • scrollstart
  • scrollstop

ps: You should use the jQuery library as jQuery mobile runs on top of it.

+11
source

You can use the TouchSwipe jQuery plugin, it is the simplest plugin when jquery was running.

https://github.com/mattbryson/TouchSwipe-Jquery-Plugin

 $(function() { $(".carousel-inner").swipe({ allowPageScroll:"auto", swipe:function(event, direction, distance, duration, fingerCount, fingerData) { if(direction == 'left'){ $(this).parent().carousel('prev'); } else if(direction == 'right') { $(this).parent().carousel('next'); } } }); }); 
0
source

All Articles