---
title: "How to add swipe feature to a image gallery?"  
description: "How to add swipe feature to a image gallery?"  
author: "Anonymous User"  
published: 2014-12-31  
updated: 2014-12-31  
canonical: https://www.mindstick.com/forum/12835/how-to-add-swipe-feature-to-a-image-gallery  
category: "jquery"  
tags: ["jquery", "javascript"]  
reading_time: 1 minute  

---

# How to add swipe feature to a image gallery?

I have an [image gallery](https://www.mindstick.com/forum/33818/how-to-use-image-gallery-slider-in-bootstrap) and I want to [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) swipe [feature](https://www.mindstick.com/articles/12788/how-to-boost-sales-using-magento-2-checkout-feature) to it,next and prev big image. I don't want to use any pluggin. I have some [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii), I tried some but I was unable to make it work. Any [advice](https://yourviews.mindstick.com/view/50528/filament-advice-5-things-to-consider-before-you-buy-a-filament) is highly appreciated.\

```
$(document).on("pagecreate","#pageone",function(){ $("img").on("swipeleft",function(){    console.log("Left");  });  $("img").on("swiperight",function(){    console.log("Right");  });                          });
```

\
Jsfiddle\
Thanks!

## Replies

### Reply by Norman Reedus

the swipeleft event listener is not available with only jQuery. You can use jQuery Mobile, or craft your own using the touchstart, touchmove, and touchend. Assuming you only want to execute something once, the following code should do:

```
var swiping = false;$('#div').on('touchmove', function (event) {  swiping = true;})$('#div').on('touchstart', function (event) {  setTimeout(function() {    if ( swiping = true ) {      console.log('swiping');    }  }, 50)})
```

The setTimeout likely isn't necessary since touchmove begins at the same time as touchstart - but I left it there in case any given browser performs differently.


---

Original Source: https://www.mindstick.com/forum/12835/how-to-add-swipe-feature-to-a-image-gallery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
