Advertisement
Shad0w

Untitled

Oct 21st, 2011
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 2.75 KB | None | 0 0
  1. var newsVisualVertical = 4;
  2. var intervalloVert = 4000;
  3. var numNewsVert;
  4. var larghezzaDivVert = 150;
  5. var altezzaDivVert = 118;
  6. var margineDivVert = 5;
  7. var newsVisualOrizzontal = 25;  
  8. var intervalloOriz = 7000;
  9. var larghezzaDivOriz = 298;
  10. var altezzaDivOriz = 96;
  11. var margineDivOriz = 1;
  12.  
  13. $(document).ready(function() {
  14.     numNewsVert = $("#jqnewsVert").children().length;
  15.     numNewsOrizzontal = $("#jqnewsOriz").children().length;
  16.     if (numNewsVert > 0) {
  17.         jqnewsVertical();
  18.     }
  19.     if (numNewsOrizzontal > 0) {
  20.         jqnewsOrizzontal();
  21.     }
  22. });
  23.  
  24. function jqnewsVertical() {
  25.     if (newsVisualVertical > numNewsVert) {
  26.         newsVisualVertical = numNewsVert;
  27.     }
  28.     for (var i = newsVisualVertical; i < numNewsVert; i++) {
  29.         $($("#jqnewsVert").children()[i]).css("opacity", "0");
  30.     }
  31.  
  32.     var gestInter = setInterval(jqNewsRotateVertical, intervalloVert);
  33.     $("#jqnewsVert").mouseover(function() { clearInterval(gestInter) });
  34.     $("#jqnewsVert").mouseout(function() { gestInter = setInterval(jqNewsRotateVertical, intervalloVert); });
  35. }
  36.  
  37. function jqNewsRotateVertical() {
  38.     $($("#jqnewsVert").children()[0]).animate({ opacity: 0 }, 1000, "linear", function() {
  39.         $($("#jqnewsVert").children()[0]).animate({ marginTop: -altezzaDivVert }, 1000, "linear", function() {
  40.         $($("#jqnewsVert").children()[0]).css("margin", margineDivVert);
  41.         $("#jqnewsVert").append($($("#jqnewsVert").children()[0]));
  42.         $($("#jqnewsVert").children()[newsVisualVertical - 1]).animate({ opacity: 1 }, 1000);
  43.         });
  44.     });
  45. }
  46.  
  47. function jqnewsOrizzontal() {
  48.     // Controllo di overflow
  49.     if (newsVisualOrizzontal > numNewsOrizzontal) {
  50.         newsVisualOrizzontal = numNewsOrizzontal;
  51.     }
  52.  
  53.     // Hide delle news superflue all'inizializzazione
  54.     for (var i = newsVisualOrizzontal; i < numNewsOrizzontal; i++) {
  55.         $($("#jqnewsOriz").children()[i]).css("opacity", "0");
  56.     }
  57.  
  58.     var gestInter = setInterval(jqNewsRotateOrizzontal, intervalloOriz);
  59.     $("#jqnewsOriz").mouseover(function() { clearInterval(gestInter) });
  60.     $("#jqnewsOriz").mouseout(function() { gestInter = setInterval(jqNewsRotateOrizzontal, intervalloOriz); });
  61. }
  62.  
  63. function jqNewsRotateOrizzontal() {    
  64.     // Hide della prima news
  65.     $($("#jqnewsOriz").children()[0]).animate({ opacity: 0 }, 1000, "linear", function() {
  66.         $($("#jqnewsOriz").children()[0]).animate({ marginLeft: -larghezzaDivOriz }, 1000, "linear", function() {
  67.             $($("#jqnewsOriz").children()[0]).css("margin", margineDivOriz);
  68.             $("#jqnewsOriz").append($($("#jqnewsOriz").children()[0]));
  69.             $($("#jqnewsOriz").children()[(newsVisualOrizzontal - 1)]).animate({ opacity: 1 }, 1000);
  70.         });
  71.     });
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement