Jump to content
Fórum Script Brasil
  • 0

Troca de Imagens


Marcelo Mussi

Question

Gente, boa tarde,

Não sei absolutamente nada de Javascript, porém achei o script perfeito para minha necessidade. Só gostaria de saber se é possível incluir um efeito tipo fade out na hora da troca de imagem. tentei procurar o código eu até achei a função mais não tenho a menos idéia de como agregar a esta função. Se possível alguém puder me ajudar eu agradeceria muitoooo!

<script language="javascript" /> 
var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;
var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("images/abertura_1.jpg")
image_list[image_index++] = new imageItem("images/abertura_2.jpg")
image_list[image_index++] = new imageItem("images/abertura_3.jpg")
image_list[image_index++] = new imageItem("images/abertura_4.jpg")

var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
//  End -->
</script>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...