Jump to content

Photo Slideshow, Smode/fade


callesson

Recommended Posts

Hello there!

 

Im new with javascript and im having this script that i got from school. And im trying to modify it a little bit. I have added a js script so the slideshow starts by it self. It works fine, but I want the pictures to like fade in, like smode. So it doesn't just change photo all quick.

 

Here is the code

 

Code from school.

$(document).ready(function () {
  // hide all but first image if we have js
  $('.large-images li:not(:first)').hide();
  // show thumbnails if we have js
  $('.small-images').show();
  // control the visibility of the control buttons
  $('.large-images img, .controls').bind("mouseenter", showControls).bind("mouseleave", hideControls);
  
  hideControls();
  
  function showControls() {
    $('.controls').show();
  }

  function hideControls() {
    $('.controls').hide();
  }
  
  $('.prev').bind("click", function() {
    prev();
    return false;
  });
  
  $('.next').bind("click", function() {
    next();
    return false;
  });
  
  $('.small-images a').bind("click", function() {
    display($(this).parent().attr('value'));
    return false;
  });
});

function prev() {
  var total = $(".large-images li").length;
  var current = $(".large-images li:visible").attr('value');
  if(current > 1) {
    display(parseInt(current)-1);
  } else {
    display(total);
  }
}

function next() {
  var total = $(".large-images li").length;
  var current = $(".large-images li:visible").attr('value');
  if(current < total) {
    display(parseInt(current)+1);
  } else {
    display(1);
  }
}

function display(num) {
  $(".large-images li").hide();
  $(".large-images li[value='"+num+"']").show();
  $('.small-images a').removeClass('selected');
  $(".small-images li[value='"+num+"'] a").addClass('selected');
}

 

Self start.

<script language="JavaScript1.1">
var image1=new Image()
image1.src="/bilder/tokyo1.jpg"
var image2=new Image()
image2.src="/bilder/tokyo2.jpg"
var image3=new Image()
image3.src="/bilder/tokyo3.jpg"
var image4=new Image()
image4.src="/bilder/tokyo4.jpg"
</script>
<script>
<!--
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<4)
step++
else
step=1
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
slideit()
//-->
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.