Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [jQuery] czemu pasek sie nie przwija
Forum PHP.pl > Forum > Przedszkole
dwwa
mam kod:

  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. function chr(){
  4. if(parseInt($("#sl1").css('margin-left'))>parseInt($("#sl1").innerWidth())){
  5. $("#sl1").css('margin-left','-='+parseInt($("#sl1").innerWidth())+'px');
  6. }
  7. }
  8. function chl(){
  9. if(parseInt($("#sl1").css('margin-left'))<300){
  10. $("#sl1").css('margin-left','+='+parseInt($("#sl1").innerWidth())+'px');
  11. }
  12. }
  13. var $html=$(".slide-mask").html();
  14. $(".slide-mask").html($html+$html);
  15. $(".slide").eq(0).attr('id','sl1');
  16. $(".slide").eq(1).attr('id','sl2');
  17. $(".slide").css('left','-'+(parseInt($("#sl1").innerWidth())+300)+'px');
  18. $("#sl1").css('margin-left','300px');
  19. function to_right(){
  20. chr();
  21. $("#sl1").animate({'margin-left': '+=300px'}, 2500, "linear", to_right);
  22. }
  23. function to_left(){
  24. chl();
  25. $("#sl1").animate({'margin-left': '-=300px'}, 2500, "linear", to_left);
  26. }
  27.  
  28. $("#slide-left").hover(function() {
  29. $("#sl1").stop(true,false);
  30. chr();
  31. $("#sl1").animate({'margin-left': '+=50px'}, 1200, "easeInQuint", to_right);
  32. },function() {
  33. $("#sl1").stop(true,false);
  34. chr();
  35. $("#sl1").animate({'margin-left': '+=50px'}, 1200, "easeOutQuint");
  36. });
  37. $("#slide-right").hover(function() {
  38. $("#sl1").stop(true,false);
  39. chl();
  40. $("#sl1").animate({'margin-left': '-=50px'}, 1200, "easeInQuint", to_left);
  41. },function() {
  42. $("#sl1").stop(true,false);
  43. chl();
  44. $("#sl1").animate({'margin-left': '-=50px'}, 1200, "easeOutQuint");
  45. });
  46. });
  47. </script>


i kod html:

  1. <!-- Slidebox -->
  2. <div id="slidebox">
  3. <a href="#" class="l_arrow" id="slide-left" title="Przewiń w lewo"><img src="./images/larrow.png" alt="" /></a>
  4. <span class="slide-content">
  5. <span class="slide-mask">
  6. <span class="slide" style="display: inline;">
  7. <?php
  8. $getCos = mysql_query("SELECT * FROM `promotions` ORDER BY `id` DESC");
  9. while ($cos = mysql_fetch_assoc($getCos)) {
  10. echo htmlspecialchars($cos['promotions']), '&nbsp;&nbsp; &bull; &nbsp;&nbsp;';
  11. }
  12. ?>
  13. </span>
  14. </span>
  15. </span>
  16. <a href="#" class="r_arrow" id="slide-right" title="Przewiń w prawo"><img src="./images/rarrow.png" alt="" /></a>
  17. </div>
  18. <span class="ile"></span>
  19. <!-- 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?
erix
Pokaż to gdzieś na żywo.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.