virtual Posted May 25, 2011 Report Share Posted May 25, 2011 I am using a fade transition which I have set to auto loop, but I would like it to stop after one loop. What do I need to change or add to the following JS. I have tried lots of different things but nothing has worked for me so far. Thanks for any help. // autoplay var autoPlayTimer; function restartPlay(){ stopPlay(); if (options.autoPlay) autoPlayTimer = setTimeout(function(){ go(curIdx<elementsCount-1? curIdx+1: 0); restartPlay(); }, options.delay + options.duration ); }; function stopPlay(){ if (autoPlayTimer) clearTimeout(autoPlayTimer); autoPlayTimer = null; }; function forceGo(event, index){ stopPlay(); event.preventDefault(); go(index) restartPlay(); } Quote Link to comment Share on other sites More sharing options...
administrator Posted May 26, 2011 Report Share Posted May 26, 2011 Just set up a counter variable, increment it on a loop and test for the counters value with each loop. Stef Quote Link to comment Share on other sites More sharing options...
virtual Posted May 26, 2011 Author Report Share Posted May 26, 2011 Stef, that sounds really simple for someone who understands the language, but could you possibly explain that in English or preferably Javascript to me? JS is like Chinese to me, I don't speak or write it and am just barely able to implement it. My brain doesn't work that way unfortunately (even after several courses) although I am fluent in several human languages. But thank you for your time and for replying. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted May 26, 2011 Report Share Posted May 26, 2011 Perhaps you can post the full code that you are using, or a include a link (or PM it to me directly) so I can see the page in action? It seems a little silly to have this autoloop functionality if you only need it to loop once. I'm betting the entire javascript could be rewritten to be a lot simpler, but I can't really tell with this small snippet. Quote Link to comment Share on other sites More sharing options...
henrylayla Posted May 26, 2011 Report Share Posted May 26, 2011 @Ben you are really helpful i had seen that you are handling the forum perfectly that's really impressive. Keep the good work going friends Quote Link to comment Share on other sites More sharing options...
virtual Posted May 26, 2011 Author Report Share Posted May 26, 2011 Thank you Ben, I have PM's you the file. Quote Link to comment Share on other sites More sharing options...
administrator Posted May 26, 2011 Report Share Posted May 26, 2011 Stef, that sounds really simple for someone who understands the language, but could you possibly explain that in English or preferably Javascript to me? JS is like Chinese to me, I don't speak or write it and am just barely able to implement it. My brain doesn't work that way unfortunately (even after several courses) although I am fluent in several human languages. But thank you for your time and for replying. Ooops, sorry about that. Do you want a copy of the Javascript basics course? Let me know ... better yet, do you have a subscription to the killer video library? Let me know I will set it up. Since Ben is on it, I will leave it to Ben. Quote Link to comment Share on other sites More sharing options...
administrator Posted May 26, 2011 Report Share Posted May 26, 2011 Perhaps you can post the full code that you are using, or a include a link (or PM it to me directly) so I can see the page in action? It seems a little silly to have this autoloop functionality if you only need it to loop once. I'm betting the entire javascript could be rewritten to be a lot simpler, but I can't really tell with this small snippet. Yep ... I agree. I just wasn't sure if you had some nuanced scenario that I was not considering - basically, you don't need to run a loop if the action has to executed only once. Loops are for repeating something many times. Stefan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.