Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [jQuery] czemu pasek sie nie przwija
dwwa
post 15.09.2011, 10:29:59
Post #1





Grupa: Zarejestrowani
Postów: 47
Pomógł: 1
Dołączył: 14.09.2011

Ostrzeżenie: (0%)
-----


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?
Go to the top of the page
+Quote Post
erix
post 15.09.2011, 12:54:00
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Pokaż to gdzieś na żywo.


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 21.06.2025 - 23:12