Link do strony
Slider
Kawałek kodu, który odpowiada za przesuwanie(całą resztę można znaleźć w źródle strony)
var sliderWidth=930; $("#thumbScroller").css("width",sliderWidth); var totalContent=0; $("#thumbScroller .content").each(function () { totalContent+=$(this).innerWidth(); $("#thumbScroller .container").css("width",totalContent+20); }); $("#thumbScroller").mousemove(function(e){ if($("#thumbScroller .container").width()>sliderWidth){ var mouseCoords=(e.pageX - this.offsetLeft); //alert(mouseCoords); var mousePercentX=mouseCoords/sliderWidth; var destX=-(((totalContent-(sliderWidth))-sliderWidth)*(mousePercentX)); var thePosA=mouseCoords-destX; var thePosB=destX-mouseCoords; var animSpeed=6000; //ease amount var easeType="easeOutCirc"; if(mouseCoords==destX){ $("#thumbScroller .container").stop(); } else if(mouseCoords>destX){ //$("#thumbScroller .container").css("left",-thePosA); //alternatywna wersja //$("#thumbScroller .container").stop().animate({left: -thePosA}, animSpeed,easeType); //oryginal $("#thumbScroller .container").stop().animate({left: -thePosA}); } else if(mouseCoords<destX){ //$("#thumbScroller .container").css("left",thePosB); //alternatywna wersja //$("#thumbScroller .container").stop().animate({left: thePosB}, animSpeed,easeType); //orginal $("#thumbScroller .container").stop().animate({left: thePosB}); } } });
Przypuszczam, że jest to wina złej z czytywanej pozycji elementu ale nie wiem jak to naprawić.
Warto dodać, że uaktywni się // alternatywna wersja a weźmie w komentarz
to działa poprawnie.
$("#thumbScroller .container").stop().animate({left: -thePosA});