Alcuinus

Slider Thing Maybe

Jul 27th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <div id="fadeBox" style="width:200px; height:200px;">
  2. <img src="https://lh5.googleusercontent.com/-QXtBl36Dl-s/AAAAAAAAAAI/AAAAAAAAAE8/R-8wXJllxyw/s100-c/photo.jpg">
  3. <img src="https://lh5.googleusercontent.com/-uQqDiQ92aZQ/TiZspaC99wI/AAAAAAAAAFE/KZU_RIKUfTI/s150-c/photo.jpg">
  4. <img src="https://lh5.googleusercontent.com/-vp16kljkPwg/AAAAAAAAAAI/AAAAAAAAAKg/Ypz8rdBRFjQ/s200-c/photo.jpg">
  5. </div>
  6.  
  7.  
  8.  
  9. function fadeInit(color){
  10. color = !color ? "#FFF" : color;
  11. $("#fadeBox img").each(function(){
  12. $(this).replaceWith( "<div>" + this.src + "</div>" );
  13. });
  14. $("#fadeBox div").each(function(){
  15. $(this).css("width",$(this).parent().width());
  16. $(this).css("height",$(this).parent().height());
  17. $(this).css("background-image","url(" + $(this).text() + ")");
  18. $(this).text("");
  19. $(this).wrap("<td style='background-color:"+color+"'>");
  20. });
  21.  
  22. $("#fadeBox td").wrapAll("<table style='position:relative; width:100%; height:100%;'><tbody><tr></tr></tbody></table>");
  23. $("#fadeBox div").show();
  24. }
  25.  
  26. function fadeShow(fadeTime, fadeDelay){
  27. var $topImage = $("#fadeBox td:last");
  28. $topImage.fadeTo(fadeDelay,1,function(){
  29. $topImage.fadeTo(fadeTime,0,function(){
  30. $topImage.fadeTo(fadeDelay,1);
  31. $topImage.insertBefore("#fadeBox td:first");
  32. fadeShow(fadeTime, fadeDelay);
  33. });
  34. });
  35. }
  36.  
  37. fadeInit("#000");
  38. fadeShow(500,1000);
  39.  
  40.  
  41.  
  42.  
  43. #fadeBox td
  44. {
  45. position:absolute;
  46. width:100%;
  47. height:100%;
  48. user-select: none;
  49. -moz-user-select: -moz-none;
  50. -khtml-user-select: none;
  51. -webkit-user-select: none;
  52. }
  53.  
  54. #fadeBox img
  55. {
  56. display:none;
  57. }
  58.  
  59. #fadeBox div
  60. {
  61. background-repeat:repeat-x;
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. http://jsfiddle.net/PvPXM/1/
Advertisement
Add Comment
Please, Sign In to add comment