Note that there are some explanatory texts on larger screens.

plurals
  1. POsetInterval is only running one time?
    primarykey
    data
    text
    <p>JSFiddle is here...</p> <p><a href="http://jsfiddle.net/Vd8PJ/10/" rel="nofollow noreferrer">http://jsfiddle.net/Vd8PJ/10/</a></p> <p>All right. I'm trying to create a JQuery carousel to display some images of different widths. To help accomplish this, I'm trying to produce a seamless, unending slide to the right on an unordered list containing images. I plan to put images that have passed the threshold behind the rest with the .before property so that it will continue forever. However, I have three problems. </p> <p>The first problem is that if my JS looks like this...</p> <pre><code>$(document).ready(function() { function gallery () { $("#image").animate({"margin-left":"200px"}, 3000); } setInterval(gallery, 3000); }); </code></pre> <p>It waits 3 seconds, and it only runs once. I did look around to see if I could fix the only running once problem, and I found this...</p> <p><a href="https://stackoverflow.com/questions/8732191/setinterval-only-running-function-once">setInterval() only running function once</a></p> <p>And many other questions like it. Always it is the same thing. They are calling the function like this...</p> <pre><code>setInterval(gallery(), 3000); </code></pre> <p>in setInterval, instead of like this...</p> <pre><code>setInterval(gallery, 3000); </code></pre> <p>So, I know that cannot be the solution. Considering my function already has no parentheses following it, and is being called the correct way. (I think.)</p> <p>So, logically I tried to fix the next problem, the three second delay. I wrote this...</p> <pre><code>$(document).ready(function() { $("#image").animate({"margin-left":"200px"}, 3000); function gallery () { $("#image").animate({"margin-left":"200px"}, 3000); } setInterval(gallery, 3000); }); </code></pre> <p>Now it runs instantly when the page loads, however since setInterval was only running once before, I would assume I would get two occurrences of...</p> <pre><code>$("#image").animate({"margin-left":"200px"}, 3000); </code></pre> <p>One that was running on load, and the other being run from the "gallery" function by setInterval. This however is not the case. It runs instantly but I only get one occurrence. </p> <p>My final problem does not have anything to do with setInterval, but I figure I would kill two birds with one stone. Because my unordered list hasa width of 9,999 pixels, does that mean even if I run the animation continuously, eventually I will run out of element to move?</p> <p>Thanks in advanced!</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.
 

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