mam kod:
<script type="text/javascript"> $(document).ready(function() {
function chr(){
if(parseInt($("#sl1").css('margin-left'))>parseInt($("#sl1").innerWidth())){
$("#sl1").css('margin-left','-='+parseInt($("#sl1").innerWidth())+'px');
}
}
function chl(){
if(parseInt($("#sl1").css('margin-left'))<300){
$("#sl1").css('margin-left','+='+parseInt($("#sl1").innerWidth())+'px');
}
}
var $html=$(".slide-mask").html();
$(".slide-mask").html($html+$html);
$(".slide").eq(0).attr('id','sl1');
$(".slide").eq(1).attr('id','sl2');
$(".slide").css('left','-'+(parseInt($("#sl1").innerWidth())+300)+'px');
$("#sl1").css('margin-left','300px');
function to_right(){
chr();
$("#sl1").animate({'margin-left': '+=300px'}, 2500, "linear", to_right);
}
function to_left(){
chl();
$("#sl1").animate({'margin-left': '-=300px'}, 2500, "linear", to_left);
}
$("#slide-left").hover(function() {
$("#sl1").stop(true,false);
chr();
$("#sl1").animate({'margin-left': '+=50px'}, 1200, "easeInQuint", to_right);
},function() {
$("#sl1").stop(true,false);
chr();
$("#sl1").animate({'margin-left': '+=50px'}, 1200, "easeOutQuint");
});
$("#slide-right").hover(function() {
$("#sl1").stop(true,false);
chl();
$("#sl1").animate({'margin-left': '-=50px'}, 1200, "easeInQuint", to_left);
},function() {
$("#sl1").stop(true,false);
chl();
$("#sl1").animate({'margin-left': '-=50px'}, 1200, "easeOutQuint");
});
});
i kod html:
<!-- Slidebox -->
<a href="#" class="l_arrow" id="slide-left" title="Przewiń w lewo"><img src="./images/larrow.png" alt="" /></a> <span class="slide-content"> <span class="slide-mask"> <span class="slide" style="display: inline;"> <?php
$getCos = mysql_query("SELECT * FROM `promotions` ORDER BY `id` DESC");
while ($cos = mysql_fetch_assoc($getCos)) {
echo htmlspecialchars($cos['promotions']), ' • ';
}
?>
<a href="#" class="r_arrow" id="slide-right" title="Przewiń w prawo"><img src="./images/rarrow.png" alt="" /></a> <!-- End slidebox -->
ten kod odpowiedzialny jest za pasek przewijany ze strzałkami, po naciśnieciu lewej tekst przewija sie w lewo, prawej w prawo. Chcialem zrobic tak, zeby pasek przewijaj sie od razu po wejsciu na strone, a po nacisnieciu na jakas strzalke szybciej w daną strone.
co moze byc nie tak?