Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jQuery] slideSwitch (ładowanie wszystkich zdjęć)
webspy
post 21.01.2013, 19:53:18
Post #1





Grupa: Zarejestrowani
Postów: 186
Pomógł: 9
Dołączył: 3.03.2008

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


Witam,

Problem polega tym że przy ładowaniu strony wczytują się wszystkie zdjęcia i długo to zchodzi,

Jak można to poprawić? chyba że to jest złe rozwiązanie i szukać innego? (patrzyłem i wszystkie takie slidery są oparte na liscie img.


  1. <div id="slideshow">
  2. <img class="active" src="image/tlo.jpg" alt="" />
  3. <img src="image/1.jpg" alt="" />
  4. <img src="image/2.jpg" alt="" />
  5. <img src="image/3.jpg" alt="" />
  6. <img src="image/4.jpg" alt="" />
  7. <img src="image/5.jpg" alt="" />
  8. <img src="image/6.jpg" alt="" />
  9. <img src="image/7.jpg" alt="" />
  10. </div>

[JAVASCRIPT] pobierz, plaintext
  1. <script type="text/javascript">
  2.  
  3. function slideSwitch() {
  4. var $active = $('#slideshow IMG.active');
  5.  
  6. if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
  7.  
  8. // use this to pull the images in the order they appear in the markup
  9. var $next = $active.next().length ? $active.next()
  10. : $('#slideshow IMG:first');
  11.  
  12. // uncomment the 3 lines below to pull the images in random order
  13.  
  14. // var $sibs = $active.siblings();
  15. // var rndNum = Math.floor(Math.random() * $sibs.length );
  16. // var $next = $( $sibs[ rndNum ] );
  17.  
  18. $active.addClass('last-active');
  19.  
  20. $next.css({opacity: 0.0})
  21. .addClass('active')
  22. .animate({opacity: 1.0}, 1000, function() {
  23. $active.removeClass('active last-active');
  24. });
  25. }
  26.  
  27. $(function() {
  28. setInterval( "slideSwitch()", 30000 );
  29. });
  30.  
  31. </script>
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post

Posty w temacie


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: 14.08.2025 - 08:44