Homer
Homer

Reputation: 1

Stop/Start Slider - Stop after one cycle

I have a project that I am working on that uses Start/Stop slider by Chris Coyier shown here http://css-tricks.com/startstop-slider. The client loves it, but now wants it to to just cycle through once and stop. Also after it cycles and stops the "Stop" button to turn to "Start" so that if the user wants to play it again they can.

I am a newbie at jquery/Javascript and am having no luck figuring this out.

Thank you for your help

Upvotes: 0

Views: 1319

Answers (1)

Matthew Nessworthy
Matthew Nessworthy

Reputation: 1428

You need to update the doMove function and clear the interval after the slide has completed 1 revolution

if (movement == tooFar) {
  $(".slide img").animate({
    "top": -200
  }, function() {
    $("#mover").animate({
      "left": 0
    }, function() {
      $(".slide img").animate({
        "top": 20
      });
    });
  });

  clearInterval(sliderIntervalID);
  $("#slider-stopper").text("Start");
}

Upvotes: 1

Related Questions