mjcoder
mjcoder

Reputation: 1011

Nivo Slider - Stop any animations when there is one image?

I am trying to stop the transition on the banner so if there is one image uploaded it doesnt loop through it - it just stays static and doesnt move about (no transitions)

I've tried using this on Nivoslider

if ($(".nivoSlider").children().length === 1)
         $(".nivo-controlNav").hide(0);

The full script here;

<script type="text/javascript">
 $(window).load(function () {
     var total = $('#slider img').length;
     var rand = Math.floor(Math.random() * total);

     if ($(".nivoSlider").children().length === 1)
         $(".nivo-controlNav").hide(0);

     $('#slider').nivoSlider({
         effect: 'fade',
         animSpeed: '500',
         pauseTime: '5000',
         startSlide: rand
     });
 });
</script>

I've also tried this;

if($('.nivoSlider').find('img').size()===1)
{
     $('.nivo-directionNav').remove();
}

How can i stop it without changing anything in the main nivoslider js file?

It happens on this page http://securushealthandsafety.co.uk/health-and-safety-training/iosh-approved-coaching-for-safety.aspx

Upvotes: 0

Views: 1116

Answers (1)

GajendraSinghParihar
GajendraSinghParihar

Reputation: 9131

Have you tried

  • first check the number of images in #slider
  • if no of image is >1 apply nivoSlider

Eg.

if ($("#slider").find("img").length > 1)
{
  $('#slider').nivoSlider({
         effect: 'fade',
         animSpeed: '500',
         pauseTime: '5000',
         startSlide: rand
     });
}

Upvotes: 1

Related Questions