jQuery – Implement touch and gesture based interaction using TouchSwipe

Here is an example for a simple swiping implementation using TouchSwipe.

<!doctype html>
<html>
<head>
  <title>Eureka! - TouchSwipe Example</title>
  <style type="text/css">
    #box {
      background-color: green;
      width: 400px;
      height: 225px;
      line-height: 225px;
      text-align: center;
    }
  </style>
</head>
<body>
  <div id="box">Swipe here!</div>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script type="text/javascript" src="js/jquery.touchSwipe.min.js"></script>
  <script type="text/javascript">
    $("#box").swipe({
      swipe: function(event, direction, distance, duration, fingerCount) {
        $(this).text("You swiped " + direction );
      }
    });  
  </script>
</body>
</html>

 

Done =)

Reference: TouchSwipe: a jQuery plugin for touch and gesture-based interaction

Advertisements

2 thoughts on “jQuery – Implement touch and gesture based interaction using TouchSwipe”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s