Preventing slider from passing last element?

Preventing slider from passing last element?

So I was looking through  ton of tutorials and plugins out there and found what I think is the simplest content slider I've ever used. It's great and it uses small enough code profile to prevent breaking everything around it.

However, I'm having this issue where if you hit the last element, and hit "Next", it will scroll to empty space, and keep going. Same with if you hit "Prev" on the first item.


  1. function slidePrev(){
        if(parseInt($("#content ul").css("left")) < 0)
        {
            $("#content ul").animate({
                left: parseInt($("#content ul").css("left"))+220+"px"
            },1000);
        }

    }


       
    function slideNext(){
        if(parseInt($("#content ul").css("left")) > -1320)
        {
            $("#content ul").animate({
                left: parseInt($("#content ul").css("left"))-220+"px"
            },1000);
        }
    }



















The author posted a response to someone pointing this out, with what he said was a fix, but all it did was give syntax errors and break the code when I used it.

Any ideas?

Secondary problem: If you press the Next or Prev button twice in succession, it will cause the slider to edge forwards or back a few pixels, mis-aligning the whole slider, and needing a page refresh to put it back. Fixable?