943,812 Members | Top Members by Rank

Ad:
Jul 2nd, 2009
0

JQuery - Help adding automatic fading slides

Expand Post »
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!

javascript Syntax (Toggle Plain Text)
  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. });
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
franko75 is offline Offline
7 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Spry selection menus
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: need help to my css horizontal menu with javascript for IE





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC