Note that there are some explanatory texts on larger screens.

plurals
  1. POSwipe function calls multiple times
    text
    copied!<p>I've created a simple JavaScript file in which I have 2 images.</p> <p>Here the person can either swipe left or right &amp; accordingly images swipes. </p> <p>Here's my code,</p> <pre><code>$('#landscapeimage1').swiperight(function (event) { //here lanscapeimage1 is canvas on which i have drawn an image. var width = window.innerWidth; var slide = "+=" + width + "px"; $('#landscapeimage').animate({ 'left': -width }, 1, function () { $('#landscapeimage1').animate({ "left": slide }, "fast", function () {}); $('#landscapeimage').animate({ "left": slide }, "fast", function () { currentImage = getPreviousImage(); currentCanvas = "landscapeimage"; drawImage(); $(this).unbind(event); return false; }); return false; }); return false; }); </code></pre> <p><strong>Initially when I swipe it works properly but if I visit the same image then it calls the same function again &amp; again until unvisited images does not come &amp; if I have visited all images then it turns into an infinite loop.</strong> </p> <p>I don't understand why this happens.</p> <p>I've tried to stop animate &amp; unbind swipe function but that's also not working.</p> <pre><code>&lt;div data-role="page" id="imagepage"&gt; &lt;div class="whiteBackground" id="landscapeimage" style="position: relative;"&gt; &lt;canvas id="image" style="z-index: 1;position:absolute;left:0px;top:0px;" height="200px" width="200px"&gt; &lt;/canvas&gt; &lt;/div&gt; &lt;div class="whiteBackground" id="landscapeimage1" style="position: relative;"&gt; &lt;canvas id="image1" style="z-index: 1;position:absolute;left:0px;top:0px;" height="200px" width="200px"&gt; &lt;/canvas&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>After debugging I've found that the animate function is calling multiple times; not the swipe function, but I can't figure out why? Please help me out.</strong></p> <p>Does any body know why this happens?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload