Javascript Image Slider / Posts /

How to stop loop?

57
How do I stop it from looping after last frame is reached??

Thanks
Steve  4 years ago   viewed: 13218    

7 Answers

2
You can implement this by using the slider's built-in functions and event handlers that are listed in Demo 4 Image Slider with Navigation Buttons.

Suppose you have 5 slides in total. Your last frame will be index=4. Add the following event handler to your page inside the script tag: <script> ... </script>
function beforeSlideChange(args) { //args[0]-next slide index, args[1]-next image, //args[2]-next caption, args[3]-next effect if(args[0]==4) imageSlider.changeOptions({ autoAdvance: false }); }
Note:
  1. The beforeSlideChange or afterSlideChange event handler is only available for licensed slider.
  2. You can also use afterSlideChange handler. But you need to use index 3 instead.
    function afterSlideChange(args) { //args[0]-currentSlide index, args[1]-currentImage if(args[0]==3) imageSlider.changeOptions({ autoAdvance: false }); }
milo   4 years ago
0
can�t make it works... sorry but my skills on javascript ar "-10"! jejejeeee
I have 2 images and want the slide stops, after displaying the second image...
I tried by a copy/paste of the sample:

function beforeSlideChange(args) {
    //args[0]-next slide index, args[1]-next image,
    //args[2]-next caption, args[3]-next effect
    if(args[0]==4) imageSlider.changeOptions({ autoAdvance: false });
}

inside the <script> tag of my html:

<script src="js-image-slider.js" type="text/javascript">
function beforeSlideChange(args) {
    //args[0]-next slide index, args[1]-next image,
    //args[2]-next caption, args[3]-next effect
    if(args[0]==4) imageSlider.changeOptions({ autoAdvance: false });
}
</script>

just changing the "4" of the sample, by "1" (according to the answer given) 
but the slide still display the slides in a loop!  =(
pleaseeee... can you help me??
thanks in advance!!

speedbit
  3 years ago
0
Please stage a simple demo online so that I can see where is wrong with your setting.
Milo   3 years ago
0
I have no way to publish it right now...
anyway, I would really appreciate if you can tell me if that THE IDEA (as I'm handling this) is right or wrong...
Right now, my html looks EXACTLY like this:

  inside the HEAD
          <script src="js-image-slider.js" type="text/javascript">
          function beforeSlideChange(args) {
              //args[0]-next slide index, args[1]-next image,
              //args[2]-next caption, args[3]-next effect
              if(args[0]==1) imageSlider.changeOptions({ autoAdvance: false });
          }
          </script>

  inside the BODY:
          <div id="sliderFrame">
               <div id="slider">
                      <img src="img/image01.jpg " />
                      <img src="img/image02.jpg" />
               </div>
              </div>

... and by this, the slider still loops from the last image... to de first!  =(
speedbit
  3 years ago
0
I am not sure without seeing all of your source code. You can see if afterSlideChange will work, or add one more slide, or check if the javascript version is the latest.....
Milo   3 years ago
0
got it!! sorry... but Im feeling so idiot! jajajajajaaa
I was adding the script changes to my html, instead of to edit the js!
I finally figure it out and by adding those lines to the js file, I could get it working EXACTLY as I want!
thank you for your support, anyway!  =)
speedbit
  3 years ago
-2

Hi, sppedbit, can you share your script, where did you add those lines in JS file

Roshan
  11 months ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: