Note that there are some explanatory texts on larger screens.

plurals
  1. POStopping an event and reinstating after animation is finished w/Javascript/jQuery
    primarykey
    data
    text
    <p>I searched and found three fairly good posts but all of them were animating at the click rather than a click sending parameters to a function that animates so neither .stop(), stop(true, true) nor event.stopPropagation() works though maybe I'm putting it in the wrong spot. Thus my question.</p> <p>What I am trying to prevent is the (for whatever reason) click-happy knob who clicks all the available links back and fourth rapidly and screws up the math used to calculate where a slider div/image should be. Once the animation stops, the image is off-kilter so I need to understand where to say, "Ok, something was clicked, don't allow any other clicks until the appropriate image has come into view."</p> <p>Again, the difference in what I'm trying to do and what I've found is that the animation call is not happening directly under the click but rather after the click has made some calculations and sent those numbers to a different function.</p> <p>I have this:</p> <pre><code> $('#navs li').click(function() { var currentLocationNum = $('li.cs_current').index(); var stepClicked = $(this).index(); if (stepClicked == currentLocationNum) { return false; } else { var lftEdgeNx = $('.slidingChartHolder').position().left; var newLeftEdge = (stepClicked - currentLocationNum) * imageWidth; moveMaster(lftEdgeNx + newLeftEdge, stepClicked); } }); </code></pre> <p>and the moving function:</p> <pre><code>function moveMaster(leftEdge, newcs_current) { $('.slidingChartHolder').fadeTo(200, .2).animate({ left: leftEdge }, "fast").fadeTo(200, 1); $('li.cs_current').removeClass('cs_current') $('li:eq('+newcs_current+')').addClass('cs_current'); if ($('li.cs_current').index() === 0) { $('#previous').addClass('hideMe'); $('#next').removeClass('hideMe'); } else if ($('li.cs_current').index()==4){ $('#previous').removeClass('hideMe'); $('#next').addClass('hideMe'); } else { $('#previous').removeClass('hideMe'); $('#next').removeClass('hideMe'); } } </code></pre> <p>thanks for some insight!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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