Jump to content

JQuery Simple Slider Issue on Navigate


HungryMind

Recommended Posts

Hi Guys,This is the link of my code preview:http://www.muhammads.../simple-slider/Everything is working perfect. But when i'm using code for auto slide.On Click Left & Right Button, My slider slides lately.I don't recognize why.This is the simple code.Please guide me friends.

<script>var cnt = 0;var track = 3;var setLeft = '';$(document).ready(function(){var canvas = $('div.canvas');var canvasWidth = canvas.width();var slides = canvas.find('ol.slides');var slidesWidth = slides.width();var single = slides.find('li');var singleWidth = single.width();var active = parseInt(canvasWidth/singleWidth);var slidesSize = single.size();var slidesCount = parseInt(slidesSize-active);var singleSlide = parseInt(single.width());var setDelay = 2000; // 1Second x 1000var reSlide = track; // 1Second x 1 $('a.left').click(function(){  track = 0;  if(cnt != 0)  {   slides.animate({left: '+=' + singleSlide});   cnt--;  }}); $('a.right').click(function(){  track = 0;  if(cnt < slidesCount)  {   slides.animate({left: '-=' + singleSlide});   cnt++;  }}); setInterval(function(){  if (track == reSlide)  {   if(cnt != slidesCount)   {	cnt++;	setLeft = '-=' + singleSlide;   }   else   {	track = reSlide;	cnt = 0;	setLeft = '+=' + (slidesWidth-canvasWidth);   }     slides.delay(setDelay).animate({left: setLeft});  }  else  {   track++;  }}, setDelay);});</script>

Edited by HungryMind
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...