Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][JavaScript] Efekt Fade w menu
Forum PHP.pl > Forum > Przedszkole
neotorrent
Witam
Mam mały problem z Efektem fadeIn mianowicie
To moja stronka:
Link
Jak widać po najechaniu na Home lub Style zmieniają się napisy na głównym pasku.
Chciałbym by po najechaniu jeden się wygaszał a drugi pojawiał wiem że da się to zrobić fadeIn i fadeOut
Próbuje próbuje czytam kombinuje i nic mądrego mi nie wyszło.
Czy ktoś pokaże, dopisze do aktualnego kodu jak to zrobić?
Wrzucam potrzebne fragmenty kodu:
  1. <!-- BEGIN Ikony -->
  2. <div id="ikonytop">
  3. <img src="img/ikony/iconatop_home.png" / onMouseOver="MM_showHideLayers('button1','','show','button2','','hide','button3','','hide','button4','','hide')">
  4. <img src="img/ikony/iconatop_style.png" / onMouseOver="MM_showHideLayers('button1','','hide','button2','','show','button3','','hide','button4','','hide')">
  5. <img src="img/ikony/iconatop_hosting.png" />
  6. <img src="img/ikony/iconatop_platnosci.png" />
  7. <img src="img/ikony/iconatop_kontakt.png" />
  8. </div>
  9. <!-- END Ikony -->
  10. <!-- BEGIN Pasek -->
  11. <div id="paseksrodek">
  12. <div id="srodekxleft">
  13. <img src="img/pasekorange/pasek_lewoplus.png" />
  14. </div>
  15. <div id="srodekx">
  16. <div id="srodekxnapisy">
  17. <div id="button1">
  18. <img src="img/pasekorange/napisypasek_home.png" />
  19. <img src="img/pasekorange/napisypasek_platnosci.png" />
  20. <img src="img/pasekorange/napisypasek_forum.png" />
  21. <img src="img/pasekorange/napisypasek_partnerzy.png" />
  22. <img src="img/pasekorange/napisypasek_kontakt.png" />
  23. </div>
  24. <div id="button2">
  25. <img src="img/pasekorange/napisypasek_webspell.png" />
  26. <img src="img/pasekorange/napisypasek_przemo.png" />
  27. <img src="img/pasekorange/napisypasek_joomla.png" />
  28. </div>


zmieniarka.js
  1. function MM_findObj(n, d) { //v4.01
  2. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  3. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  4. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  5. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  6. if(!x && d.getElementById) x=d.getElementById(n); return x;
  7. }
  8.  
  9. function MM_showHideLayers() { //v6.0
  10. var i,p,v,obj,args=MM_showHideLayers.arguments;
  11. for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  12. if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
  13. obj.visibility=v; }
  14. }


CSS
  1. /* Zmieniarka CSSy */
  2. #button1{
  3. visibility: show;
  4. }
  5. #button2{
  6. visibility: hidden;
  7. margin-top: -18px;
  8. }


Z góry dziękuje , myślę że mi pomożecie ;D
Wiem że rozwiązanie jakie tu zastosowałem nie jest wyszukane przyjmę każda działającą propozycje smile.gif
Kamyk24
W sumie też mam problem podobnej natury ;/ Przyłączam się do prośby może coś mi się przyda z tego.
neotorrent
Siemka to znowu ja, nie będę zakładał nowego tematu bo ciągle walczę z tym samym tongue.gif

Zrobiłem coś takiego
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Dokument bez tytułu</title>
  5. <script src="http://code.jquery.com/jquery-latest.js"></script>
  6. <style type="text/css">
  7. <!--
  8. #button1 {
  9. display:none;
  10. }
  11. #button2 {
  12. display:none;
  13. }
  14. #button3 {
  15. display:none;
  16. }
  17. #button4 {
  18. display:none;
  19. }
  20. #button5 {
  21. display:none;
  22. }
  23. -->
  24. </head>
  25.  
  26. <div id="przycisk1">Zakładka numer 1</div>
  27. <div id="przycisk2">Zakładka numer 2</div>
  28. <div id="przycisk3">Zakładka numer 3</div>
  29. <div id="przycisk4">Zakładka numer 4</div>
  30. <div id="przycisk5">Zakładka numer 5</div>
  31. <div id="button1">To jest tekst numer 1 bla bla bla</div>
  32. <div id="button2">To jest tekst numer 2 bla bla bla</div>
  33. <div id="button3">To jest tekst numer 3 bla bla bla</div>
  34. <div id="button4">To jest tekst numer 4 bla bla bla</div>
  35. <div id="button5">To jest tekst numer 5 bla bla bla</div>
  36.  
  37.  
  38. $("div").filter( document.getElementById("przycisk1") ).mouseover(function() {
  39. $('#button2').fadeOut('fast', function () {
  40. $('#button3').fadeOut('fast', function () {
  41. $('#button4').fadeOut('fast', function () {
  42. $('#button5').fadeOut('fast', function () {
  43. $('#button1').fadeIn('slow');
  44. });
  45. });
  46. });
  47. });
  48. });
  49.  
  50. $("div").filter( document.getElementById("przycisk2") ).mouseover(function() {
  51. $('#button1').fadeOut('fast', function () {
  52. $('#button3').fadeOut('fast', function () {
  53. $('#button4').fadeOut('fast', function () {
  54. $('#button5').fadeOut('fast', function () {
  55. $('#button2').fadeIn('slow');
  56. });
  57. });
  58. });
  59. });
  60. });
  61. $("div").filter( document.getElementById("przycisk3") ).mouseover(function() {
  62. $('#button1').fadeOut('fast', function () {
  63. $('#button2').fadeOut('fast', function () {
  64. $('#button4').fadeOut('fast', function () {
  65. $('#button5').fadeOut('fast', function () {
  66. $('#button3').fadeIn('slow');
  67. });
  68. });
  69. });
  70. });
  71. });
  72. $("div").filter( document.getElementById("przycisk4") ).mouseover(function() {
  73. $('#button1').fadeOut('fast', function () {
  74. $('#button2').fadeOut('fast', function () {
  75. $('#button3').fadeOut('fast', function () {
  76. $('#button5').fadeOut('fast', function () {
  77. $('#button4').fadeIn('slow');
  78. });
  79. });
  80. });
  81. });
  82. });
  83. $("div").filter( document.getElementById("przycisk5") ).mouseover(function() {
  84. $('#button1').fadeOut('fast', function () {
  85. $('#button2').fadeOut('fast', function () {
  86. $('#button3').fadeOut('fast', function () {
  87. $('#button4').fadeOut('fast', function () {
  88. $('#button5').fadeIn('slow');
  89. });
  90. });
  91. });
  92. });
  93. });
  94.  
  95.  
  96. </body>
  97. </html>


No i wszystko ładnie pięknie dopóki nie zacznę szybko przesuwać po przyciskach, wtedy napisy się dublują i efekt można zobaczyć Tutaj: Link
1. Pierwsze pytanie jak pozbyć się tego efektu ?
2. Co złego jest w Tym zapisie
  1.  
  2. $("div").filter( document.getElementById("przycisk1") ).mouseover(function() {
  3. $('#button2', '#button3', '#button4', '#button5').fadeOut('fast');
  4. $('#button1').fadeIn('slow');
  5. });
  6.  
  7. $("div").filter( document.getElementById("przycisk2") ).mouseover(function() {
  8. $('#button1', '#button3', '#button4', '#button5').fadeOut('fast');
  9. $('#button2').fadeIn('slow');
  10. });
  11. $("div").filter( document.getElementById("przycisk3") ).mouseover(function() {
  12. $('#button1', '#button2', '#button4', '#button5').fadeOut('fast');
  13. $('#button3').fadeIn('slow');
  14. });
  15. $("div").filter( document.getElementById("przycisk4") ).mouseover(function() {
  16. $('#button1', '#button2', '#button3', '#button5').fadeOut('fast');
  17. $('#button4').fadeIn('slow');
  18. });
  19. $("div").filter( document.getElementById("przycisk5") ).mouseover(function() {
  20. $('#button1', '#button2', '#button3', '#button4').fadeOut('fast');
  21. $('#button5').fadeIn('slow');
  22. });
  23.  
  24.  

Bo on u mnie nie działa ;(

Dzięki z góry smile.gif
Kostek.88
http://jsfiddle.net/kostek/kGWFB/ - looknij tu, ew. zamien hide() na fadeOut... o cos takiego Ci chodzilo?

EDIT: ew. krotsza wersja: http://jsfiddle.net/kostek/kGWFB/2/

Co do zapisu, to wydaje mi sie, ze :

  1.  
  2. $('#button5').fadeOut('fast', function () {
  3. $('#button2').fadeIn('slow');
  4. });
  5.  


jesli fadeout zostanie zakonczony, wykonaj fadeIn innego div-a. Jesli w miedzyczasie wywolasz inny fadeout, to efekt ten podmienia sie i w rezultacie ten div nie znika, bo efekt sie nie zakonczy nigdy... tak na szybko napisalem to, wiec wybaczcie bledy.
neotorrent
Hmm daje pomógł bo troszkę lepiej działa, ale jak tak sie bardzo szybko przejedzie to i tak sie dubluje ;/ kurcze no też tak domyślałem się ze jedna warstwa nie zdąży się schować a już następna jest. Co to jeszcze można by zaradzić ?
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.