Question about a Image carousal
I am creating a image carousal for a project, my client wants it to slide through animation and stop when it reaches the end of the line, I have then next button working but I am getting many errors with the previous button. Anyone have any ideas
- $(function(){
var maxView=$('ul#viewer').innerWidth();
var minView= maxView-$('#container').innerWidth();
var $myView=$("#viewer");
var size=$("li.photoHolder").innerWidth();
var current =maxView;
$("#btnNext").attr("disabled", false);
$("#btnPrev").attr("disabled", true);
-
$("#btnNext").click(function(){
$("#btnPrev").attr("disabled", false);
if( current > 770)
{
$myView.animate({left:"-="+size});
current-=size;
console.log(current);
}
else
{
$("#btnNext").attr("disabled", true);
$myView.stop();
}
});
$("#btnPrev").click(function(){
$("#btnNext").attr("disabled", false);
if( current+size >1044 )
$myView.animate({left:"+="+size});
current+=size;
console.log(current);
}
else
{
$("#btnPrev").attr("disabled", true);
$myView.stop();
}
});
});
-