SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Add Fading To Simple Slider?

    How do I go about adding a fade in and out to this slider? I tried playing around with animate but it didn't seem to help. Should / Do I need to preload the image before I animate it / fade it or something?

    Code:
    $(document).ready(function () {
    	var $next, 
    		cycle;
    	var i = 0;
    	var imgArr = ['1.jpg', '2.jpg', '3.jpg'];
    		
    	$activeLi = $("#slideshow li:first");
    	$activeLi.html('<img src="images/' + imgArr[i] + '" />');
    	cycle = setInterval(change_img, 1000);
    	
    	function change_img(){
    		clearInterval(cycle);
    		$activeLi.html('<img src="images/' + imgArr[i] + '" />');
    		
    		i = (i == (imgArr.length - 1)) ? 0 : ++i;
    		cycle = setInterval(change_img, 1000);
    	}
    });

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,996
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    Could you post a link to a page where I can see the slider in action?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •