Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery - slideshow buttons function
    primarykey
    data
    text
    <p>I have here a slideshow: <a href="http://jsfiddle.net/Jtec5/33/" rel="nofollow noreferrer">fiddle</a><br> Codes: CSS:</p> <pre><code>#slideshow { margin: 50px auto; position: relative; width: 240px; height: 240px; padding: 10px; box-shadow: 0 0 20px rgba(0, 0, 0, 0.4); } #slideshow &gt; div { position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px; } #slideshow img { max-width:240px; max-height:240px; } ul { list-style:none; margin:0px; padding:0px; } ul li { float:left; border-radius:10px; width:10px; height:10px; border:1px solid white; background:grey; } ul li.active { background:black; } </code></pre> <p>HTML:</p> <pre><code>&lt;div id="slideshow"&gt; &lt;div&gt; &lt;img src="http://farm6.static.flickr.com/5224/5658667829_2bb7d42a9c_m.jpg" /&gt; &lt;/div&gt; &lt;div&gt; &lt;img src="http://farm6.static.flickr.com/5230/5638093881_a791e4f819_m.jpg" /&gt; &lt;/div&gt; &lt;div&gt; &lt;img src="http://gillespaquette.ca/images/stack-icon.png" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;ul&gt;&lt;/ul&gt; </code></pre> <p>Jquery:</p> <pre><code>$("#slideshow &gt; div:gt(0)").hide(); var maxindex = $('#slideshow &gt; div').length; var index = 0 var interval = 3 * 1000; // 3 seconds var timerJob = setInterval(traverseSlideShow, interval); function traverseSlideShow() { console.log("current index: " + index); $('#slideshow &gt; div') .stop() .fadeOut(1000); $('#slideshow &gt; div').eq(index) .stop() .fadeIn(1000); $('ul li').removeClass('active'); $('ul li:eq(' + index + ')').addClass('active'); index = (index &lt; maxindex - 1) ? index + 1 : 0; } for (var i = 0; i &lt; maxindex; i++) { $('ul').append('&lt;li class="' + (i == 0 ? 'active' : '') + '"&gt;&lt;/li&gt;'); } $(document).on('click', 'ul li', function () { index = $(this).index(); traverseSlideShow(); clearInterval(timerJob); timerJob = setInterval(traverseSlideShow, interval); }); </code></pre> <p>As you can see in the slideshow, when you click one of the buttons (<img src="https://i.stack.imgur.com/TaApk.png" alt="enter image description here">) the slideshow goes to a photo that the button you clicked is related with.<br> What I'm trying to do is very simple, the function accept 1 request every 1 second at maximum so user can not spam-click on the buttons, that means the function should break 1 second with every click and prevent loading a different image for different button through this 1 second(in this 1 second the slideshow should load the photo requested).<br> I'm trying to make my question more clear, lets say we have the three buttons 1, 2, 3 click on button 1 the function takes 1 second to load the photo(through that 1 second if you click the button 2 or 3 the function doesn't load the photo for 2 or 3), and so on.</p>
    singulars
    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