JQuery - Help adding automatic fading slides

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Dec 2008
Posts: 7
Reputation: franko75 is an unknown quantity at this point 
Solved Threads: 0
franko75 franko75 is offline Offline
Newbie Poster

JQuery - Help adding automatic fading slides

 
0
  #1
Jul 2nd, 2009
Hi, I have a slideshow set up on my site which allows users to click back and forward to view images - the transition is an animated slide to the next image. But I now want to set up an automatic fade, which fades in the next image on a timer. I'm not entirely sure how to set this up and how to integrate this with my current script without conflicting with it.

Here is what I have so far for the onclick slide animation. If anyone can help with some advice to get me started with the auto fading that would be great!

  1. // project animations
  2. $("#featured").hover(function(){
  3. $(this).find(".bottom-slide").animate({bottom:"0"},{queue:false,duration:350});
  4. $(this).find(".arrow-left").animate({left:"0"},{queue:false,duration:350});
  5. $(this).find(".arrow-right").animate({right:"0"},{queue:false,duration:350});
  6. }, function(){
  7. $(this).find(".bottom-slide").animate({bottom:"-66px"},{queue:false,duration:350});
  8. $(this).find(".arrow-left").animate({left:"-50px"},{queue:false,duration:350});
  9. $(this).find(".arrow-right").animate({right:"-50px"},{queue:false,duration:350});
  10. });
  11.  
  12. // project arrows
  13. var currentFeatureSlide = 1;
  14. var currentFeatureLocation = 0;
  15. $("a.arrow-left").fadeTo(0,0.2);
  16.  
  17. var totalFeatureSlides = Math.ceil( ($(".featured-entry > div").size()) );
  18.  
  19. $("a.arrow-right").click(function(event){
  20.  
  21. if (currentFeatureSlide != totalFeatureSlides) {
  22.  
  23. if (currentFeatureSlide == 1) { $("a.arrow-left").fadeTo(300,0.75); }
  24. newFeatureLocation = (currentFeatureLocation + 512);
  25.  
  26. $(".featured-entry").animate({left:"-"+newFeatureLocation},{queue:false,duration:450});
  27.  
  28. currentFeatureSlide++;
  29. if (currentFeatureSlide == totalFeatureSlides) {
  30. $("a.arrow-right").fadeTo(300,0.2); }
  31. currentFeatureLocation = newFeatureLocation;
  32.  
  33. }
  34.  
  35. });
  36.  
  37. $("a.arrow-left").click(function(event){
  38.  
  39. if (currentFeatureSlide != 1) {
  40.  
  41. if (currentFeatureSlide == totalFeatureSlides) {
  42. $("a.arrow-right").fadeTo(300,0.75); }
  43.  
  44. newFeatureLocation = (currentFeatureLocation - 512);
  45.  
  46. if (currentFeatureSlide > 2) {
  47. newFeatureLocationNum = "-"+newFeatureLocation; } else {
  48. newFeatureLocationNum = newFeatureLocation; }
  49. $(".featured-entry").animate({left:newFeatureLocationNum},{queue:false,duration:450});
  50. currentFeatureSlide--;
  51. if (currentFeatureSlide == 1) {
  52. $("a.arrow-left").fadeTo(300,0.2); }
  53. currentFeatureLocation = newFeatureLocation;
  54.  
  55. }
  56. });
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC