BleepingComputer.com: fade images in and out w/ javascript

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

fade images in and out w/ javascript

#1 User is offline   gorydragon 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 55
  • Joined: 10-October 09

  Posted 21 March 2010 - 05:07 PM

hey take a look at this website www.jefgc.com

they used flash to make the pictures come in and out like that, how would i go about doing it with javascript?
im pretty sure its an easy thing to do, but im trying to learn js on my own, so i havent been able to figure it out..

all help is very appreciated :thumbsup:

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 21 March 2010 - 06:16 PM

http://clagnut.com/sandbox/imagefades/
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   gorydragon 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 55
  • Joined: 10-October 09

Posted 21 March 2010 - 09:00 PM

thanks, how can i stagger them a bit? so 1 loads, 2 loads, 3 loads.

#4 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 22 March 2010 - 07:03 AM

Do you mean side-by-side, so there are (for instance) 3 sets of images that are displayed?
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#5 User is offline   gorydragon 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 55
  • Joined: 10-October 09

Posted 22 March 2010 - 02:19 PM

yeah, i want the same effect as on the jefgc.com site, except using javascript rather than Flash.

#6 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 22 March 2010 - 02:54 PM

When the page loads, use an onload function to fade in the images, taking the id of the div as a parameter. So something like this:
function initImage(elementId) {
  image = document.getElementById(elementId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


Then you would create a new function something like the following:
function fadeImage(){
  initImage(element1);
  initImage(element2);
  initImage(element3);
}


Then your onload function call becomes this:
window.onload = function() {fadeImage()}

"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#7 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 30 March 2010 - 10:46 AM

Ive just done some fading for a contact form, take a look into jQuery, for example...

$(document).ready(function() {

// As the document becomes "ready", hide the image.
$("#myImage").hide();

// Now you want it to fade in from hidden.
$("#myImage").fadeIn("slow");

});


If that doesn't help here is a page on it.

Hope this helps, Wolfy87.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users