JavaScript - Simple Image Fade In From Thumbnail Click Required For Gallery...
Hi,
I'm have set up a gallery site, pretty standard stuff with thumbnails to the right and big image to the left. I would like to add a fade in on the big image when the thumbnail is clicked and don't really know how to implement it. The big images are contained in a div called <#left> while the thumbs are within a div called <div class="gallery"> I have searched Google and these forums for a solution but haven't had any luck...can anyone help me out with this? Thanks J Similar TutorialsI need help finding a script where you have a main picture and then below that will be thumbnails and when you click on them they are shown where the main picture is. Thank you Hi! I'm wondering if somebody here could help me please. I'm trying to develope the image slideshow using PHP and JavaScript. The idea is that the PHP file gets random images from the folder, i'm using session to prevent repeating the same image and then JavaScript generates the fade slideshow using that PHP file. I've come up with the solution to use two img tags in the HTML page, so JavaScript then swap them around and play with opacity, but unfortunately couldn't make it work. Everything I have tried in JavaScript didn't work properly. I'd be grateful for any help and advice guys. Thank you. My PHP code: PHP Code: <?php class images { var $images = Array(); var $imgDir = 'images/'; function getImages() { $images = Array(); if ($dir = opendir($this->imgDir)) { while(($file = readdir($dir)) !== false) { if(preg_match('#(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)#i', $file)) $images[] = $file; } closedir($dir); } return $images; } function getNextImage() { if (($images = $this->getImages()) !== false) { session_start(); if (!isset($_SESSION['image'], $images[$_SESSION['image']])) { $index = mt_rand(0, count($images)-1); } else { $index = $_SESSION['image'] == count($images)-1 ? 0 : $_SESSION['image']+1; } $_SESSION['image'] = $index; return $images[$index]; } return false; } function outputImage() { if (($file = $this->getNextImage()) !== false) { header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Wed, 9 Dec 1981 07:00:00 GMT'); // Date in the past header('Content-type: image/jpg'); readfile($this->imgDir.$file); exit(); } } } $img = new images(); $img->outputImage(); ?> My HTML page: Code: <html> <head> <title>Images</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script type="text/javascript" src="javascript/slideshow2.js" language="javascript"></script> </head> <body onload="startSlideShow();"> <h1>Images</h1> <div id="imageWrap"> <div id="images"> <img id="sampleImgFade" src="images.php" alt="images" style="filter:progid:DXImageTransform.Microsoft.alpha(opacity=0);-moz-opacity:0;-khtml-opacity:0;" width="800" height="600" onload="coverLoaded(this);" /> <img id="sampleImg" src="images.php" width="800" height="600" alt="images" onload="mainLoaded();" /> </div> </div> </body> </html> CSS code: Code: #imageWrap { clear: both; } #images { position: relative; clear: both; } #sampleImgFade { position: absolute; top: 0px; left: 0px; } JavaScript code which doesn't work properly(just to show in which direction I'm going): Code: var img; var loaded = new Array(); loaded['start'] = true; loaded['main'] = false; loaded['cover'] = true; var fade = 0; var i = 0; function getImage() { img = new image(); img.src = "images.php"; } function coverLoaded(obj) { loaded['cover'] = true; setOpacity(obj, 100); window.setTimeout("startFade", 5000); } function mainLoaded() { loaded['main'] = true; if (loaded['start'] && loaded['cover'] && loaded['main']) startFade(); } function startFade() { loaded['start'] = false; loaded['main'] = false; loaded['cover'] = false; fade = window.setInterval("fadeIn()", 50); } function fadeIn() { var obj = document.getElementById("sampleImgFade"); var opacity = getOpacity(obj); if (opacity > 0) { setOpacity(obj, opacity-5); } else { window.clearInterval(fade); document.getElementById("sampleImg").src = "images.php?u="+i++; } } function getOpacity(obj) { if (obj.filters) { return obj.filters.item("DXImageTransform.Microsoft.Alpha").Opacity; } else if (obj.style.MozOpacity) { // mozilla return obj.style.MozOpacity*100; } else if (obj.style.KhtmlOpacity) { // konquerer return obj.style.KhtmlOpacity; } else { // not supported return 0; } } function setOpacity(obj, opacity) { if (obj.filters) { obj.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opacity; } else if (obj.style.MozOpacity) { // mozilla obj.style.MozOpacity = opacity/100; } else if (obj.style.KhtmlOpacity) { // konquerer obj.style.KhtmlOpacity = opacity; } } Dear Experts, I am very new for javascript so I am not even sure it is possible or not. The situation is like this, I have a page, which is actually a photo gallery with a table having 3 rows. First row shows the full screen size pic. Second row displays the Caption of that image and third row shows thumbnail view of six different images and the previous and next button. this is the sample layout: <table> <tr> <td colspan=8> Full size image will be shown in this cell </td> </tr> <tr> <td colspan=8> Caption of the image will be displayed here </td> </tr> <tr> <td>Previous Button</td> <td>Pic1 thumbnail view</td><td>Pic2 thumbnail view</td><td>Pic3 thumbnail view</td> <td>Pic4 thumbnail view</td><td>Pic5 thumbnail view</td><td>Pic6 thumbnail view</td> <td>Next Button</td> </td> </tr> My requirement is whenever the user click on the thumbnail view, which is in the 3rd row, the corresponding full screen size pic should open in 1st row of the table. As my photo gallery should be having more than 6 pics, lets take 20 pics, I want to show only 6 thumbnails in 3rd row at a time. Whenever user press "Next" button the 3rd row having 6 thumbnails should show other 6 thumbnails and previous button should show previous 6 thumbnails. I have a guess that it can be done using arrays, but how????? I have no idea. So please if you have any guesses it will be nice if you can post the entire code here as I will not be in a position to work on the hints given by you. Thanks in advance. Charles hello everyone. i am new to this forum and new with webdesigning.. i was wondering if anyone can help guide me to get the right coding im trying to make it so that when clicking thumbnails it will change the full screen background to its respective picture along with continuing its automatic slideshow www.petpawfurry.com is the website in which im working on. also, is there anyway to make the slider, slide to the right, instead of fading in and out? thanks so much, hope someone can help Hello everyone, I am sorry to take up your time, I need help with some small issues, I am not familiar with java / php. I will post my problems on different threads. --- N0 1 is: I need a image gallery like this: Big image is 540px wide and beneath it is a thumbnail that activates the big image on click. I have one now but I am not satisfied with it. The link is: http://sfantipa.ro/gal_iarna.html . What I do not like is the fact that it scales the vertical images as the same weight and distorts them and I want the thumbnails to be on 1 row with before and next < > buttons or scrolled by mouse over at the left and right row, doesnt really matter which one. The thumbnail will have some space between them but they will load them as they are not scale them to predefined w/h. No text description and the thumbnails are always displayed, not hide... I am asking here because although I found many scripts, none is the one I need Can anyone help please? Thanks fokes! Okay, I've already learned from google how to make the following two simple image galleries: This one displays a specific image when its link is clicked And this one displays the previous/next image for whatever's showing. (During its code, it points to this .js file.) My question is, how do I combine those two galleries? How can I make one gallery that contains both kinds of links? Since the two galleries were copied from different places, the names they use aren't the same, and I'm not sure what to change to make it all unified. (I tried fiddling with it for over an hour before giving up.) Let me know if you need any more info from me. This is a really awesome script that I'm sure all of you can put to use if you haven't yet heard of it. However, I'm trying to get it to fade a background image on my css styled navigation for my a:hover. Here is the script with a little simple tutorial on how to set it up: http://bavotasan.com/tutorials/creat...r-fade-effect/ My only other knowledge is in PHP, so after about 2 hours of fail in this client-side language, I decided it was about time I should post where some experienced people can help. I really appreciate all time you spend on this, and don't think it will take a moderate Javascript programmer very long. This is the link to my site so far: http://matt.mw/help-request You can see the script working as it is on my little yellow MW logo on the right side of the navigation. So in my scenario, I am looking to fade button.png to button-hover.png (both repeating on the x axis). Any ideas? Hello, Currently I'm looking at smooth scrolling Js scripts for thumb images which can be altered to accomodate needs. I found one here that has some desirable effects but has no navi buttons. Would it be sensible to alter and point the hovering mouse scroll function to buttons, or would it be a better idea to keep looking for exactly the right script? The 2 identical scrollers on this page are the look I want but these are flash; http://area.autodesk.com/ ps: I've no experience of Js but can pick things up pretty quickly. Hi I have a script that is driving me slightly crazy...I need to use different images as the thumbnails on this page. I want to use specified crops of the image rather than what is there now (the larger image squeezed down). Does anyone have any idea how I could do that? Thanks a million. http://www.annaleithauser.com/rosema...e/country.html Hey all.. I just finished a semester at the local junior college in javascript programming. Didnt teach us very well, but I learned several basics. I have skills in several different aspects of programming now, but none as an expert by any means. Now, I am working on a project for my wife's non-profit that she is involved in, and an wanting to create a thumbnail sized picture 'band' at the top of my website, with images of things that she wants the user to be able to click on to pop up a bigger picture into a new window, a popup window, mind you. This 'image gallery', needs to be able to be clicked on to move the images to the left or to the right, and display, maybe 5 to seven images at a time in about a 100px height band. I have seen this on other websites before, and I have the software to do my own programming, and I 'should have' developed the skills by now, lol, but, I just need some help getting started in the right direction in knowing how to start out. Like, what do I need to accomplish to do this? I already have a div set up for the container for it. The website is using a combination of html, css, php, mysql and javascript. Thank you; Ice hi I am creating a gallery using my flickr feed. I have the bones of it working the only issue is with the thumbnail pulled from flickr. You get the option of small medium and large whicj Im using meduim. I want to add an image border around the thumbnails using a background image but when I add the styles it wont work. If i add a width to the img tag it will distrit the images because its being pulled from the flickr api anyone any ideas on how to get the background image working? html code is here Code: <body> <!-- Some Content --> <div id="gallery"> <input type='hidden' id='current_page' /> <input type='hidden' id='show_per_page' /> <div id="flickr"> </div> <div id='page_navigation'></div> </div> </body> CSS for the img is Code: [.hidden { display: none; } div#flickr a.lightbox img { border: 5px solid #b3aaa4; margin-left: 5px; margin-right: 5px; margin-bottom:30px } and the java script is here Code: $(function() { $.getJSON('http://api.flickr.com/services/rest/?format=json&method='+ 'flickr.photos.search&api_key=' + apiKey + '&user_id=' + userId + '&tags=' + tag + '&per_page=' + perPage + '&jsoncallback=?', function(data){ var classShown = 'class="lightbox"'; var classHidden = 'class="lightbox hidden"'; $.each(data.photos.photo, function(i, rPhoto){ var basePhotoURL = 'http://farm' + rPhoto.farm + '.static.flickr.com/' + rPhoto.server + '/' + rPhoto.id + '_' + rPhoto.secret; var thumbPhotoURL = basePhotoURL + '_m.jpg'; var mediumPhotoURL = basePhotoURL + '.jpg'; var photoStringStart = '<a '; var photoStringEnd = 'title="' + rPhoto.title + '" href="'+ mediumPhotoURL +'"><img src="' + thumbPhotoURL + '" alt="' + rPhoto.title + '"/></a>;' var photoString = (i < showOnPage) ? photoStringStart + classShown + photoStringEnd : photoStringStart + classHidden + photoStringEnd; $(photoString).appendTo("#flickr"); }); $("a.lightbox").lightBox(); }); }); anyone? I have a script that fades links on load and im trying to get this to work on everything but the menu link that has the "active" class Code: <div id="menu"> <ul><li id="Home"><a title="Home" href="/" style="opacity: 0.6;">Home</a></li> <li class="active" id="projects"><a title="projects" href="/projects/" style="opacity: 0.6;">projects</a></li> <li class="last" id="Contact"><a title="Contact" href="/contact" style="opacity: 0.6;">Contact</a></li> </ul> </div> and here is the javascript.. (JQuery) Code: $(document).ready(function(){ $("#menu a").fadeTo("slow", 0.6); // This sets the opacity of the menu to fade down to 60% when the page loads $("#menu a").hover(function(){ $(this).fadeTo("slow", 1.0); // This should set the opacity to 40% on hover },function(){ $(this).fadeTo("slow", 0.6); // This should set the opacity back to 100% on mouseout }); }); What do I add so any "<li>" that has the class "<li class="active"> isnt effected by the javascript so it just displays at 1.0 instead of 0.6? Hi all. I'm learning JS from pretty much scratch and the first thing I'm trying to do is simply make an image fade function. I just can't seem to make it work though, the image starts off at the right opacity (im this case 0.5) but after that the page goes white and the script never stops. It does seem to be counting up normally "opacity: 0.6 opacity: 0.7" etc. though. Code: <img src="1.jpg" id="pic1"> <script type="text/javascript"> var amount = 0.5; var target = document.getElementById('pic1'); function fade() { if (target.style.opacity < 1.0) { target.style.opacity = amount; amount = amount + 0.1; document.write("<br>opacity: " + target.style.opacity); setTimeout("fade()", 1000) //fade(); } } fade(); </script> edit I rewrote it to make it simpler but still having basically the same problem D:! I have gotten my script to do exactly what I want it to do with one exception. I have some thumbnail images that people can mouse over and the actual image is 100px by 75px. That is what I use for my thumbnail and they reside in www.website.com/images/thumbs/image1.jpg. I have the large version of the image that resides in www.website.com/images/image1.jpg. Its actual size is 640px by 480. When I mouse over my thumbnail, I don't want the thumbnail to appear for the larger image, I want the large image to appear instead? Let me know if you need ellaboration. Any help would be great! Thank you. Javascript Code: <script language="JavaScript"> function Change_Big_One(thumb){ document.getElementById('BigOne').src=thumb.src.replace("_th","") } </script> HTML THUMBNAIL Code: <div><img src="https://www.website.com/images/thumbs/image1.jpg" class="thumb" onMouseOver="Change_Big_One(this)"></div> HTML LARGER IMAGE Code: <div><img src="" id="BigOne"></div> Hi All, Am a newbie here, and am probably way out of my depth but here goes... I have the following code (this is a snippet) Code: else if(sortValue == "lh"){window.location="?"+searchParam+"range=&sort1desc=F&sort1=Item_ONLINECUSTOMERPRICE";} I would like to say "Just show "Item_ONLINECUSTOMERPRICE" between 0 and 100. How would I achieve that please? Any help Appreciated Hi there, I am new to java script and jquery, so please use small words. so my website, threedash.com (in production), the main page has a simple fade jquery plugin, that i want to implement with a lightbox added when the user clicks on the image. I hope this wasn't too confusing.. _threedash thankyou for taking the time to read this post. I have this code... I want to be able to make each image fade from one to the other. Like this... http://www.dynamicdrive.com/dynamici...nslideshow.htm Is there a way to do that with this code? Code: <script type="text/javascript"> // Simple Javascript Time based Image Swap var Pics = new Array(); var counter = 0; // Use this section to change the image paths function LoadImages() { Pics[1] = new Image(); Pics[1].src = "images/pic1.jpg"; Pics[2] = new Image(); Pics[2].src = "images/pic2.jpg"; Pics[3] = new Image(); Pics[3].src = "images/pic3.jpg"; Pics[4] = new Image(); Pics[4].src = "images/pic4.jpg"; Pics[5] = new Image(); Pics[5].src = "images/pic5.jpg"; Pics[6] = new Image(); Pics[6].src = "images/pic6.jpg"; Pics[7] = new Image(); Pics[7].src = "images/pic7.jpg"; Pics[8] = new Image(); Pics[8].src = "images/pic8.jpg"; Pics[9] = new Image(); Pics[9].src = "images/pic9.jpg"; Pics[10] = new Image(); Pics[10].src = "images/pic10.jpg"; Pics[11] = new Image(); Pics[11].src = "images/pic11.jpg"; Pics[12] = new Image(); Pics[12].src = "images/pic12.jpg"; Pics[13] = new Image(); Pics[13].src = "images/pic13.jpg"; Pics[14] = new Image(); Pics[14].src = "images/pic14.jpg"; Pics[15] = new Image(); Pics[15].src = "images/pic15.jpg"; Pics[16] = new Image(); Pics[16].src = "images/pic16.jpg"; Pics[17] = new Image(); Pics[17].src = "images/pic17.jpg"; document.pic1.src = Pics[1].src; } //Time in miliseconds function timedImage() { counter ++ if (counter > 17) { counter = 1; } document.pic1.src = Pics[counter].src; t=setTimeout("timedImage()",5000); } </script> I've been looking for a way to fade a selection of images in on load while keeping their background present until they fade in. similar to whats been used on this site: http://inventorystudio.co.uk/ thought this would be relatively simple but seems to be harder than i expected. any suggestions? Ive searched everywhere for an image gallery script which shows only thumbnails. -Ive found none =/ What i want is something like this: http://www.dhtmlgoodies.com/scripts/...ideshow-5.html BUT i do want just the small thumbnails thats slideable. The below gallery-link is what I want, but it should be sliding like the thumbnails in the above gallery so that I don't have to place 100 pictures in one page. http://www.gethifi.com/demos/jphotogrid Ive found galleries in flash, but it would be great to not have to use flash.. an1 knows about a script like the one in my description? Im not awsome at scripts. I know a little, and have tried to modify some scripts, but ive given up Hi, Hope that someone can help me with a little problem I have. I building a little page that has some photos of the family. Ive created little thumbnails and large versions of each image. What im trying to achieve is that in div a: i have each of the thumbnails and in div b: it displays a large verison on the image thats clicked. Ive seen a few methods when searching using java and ajax etc, but i'm not sure which is the best way to do this and the most simple so that I dont have to create a new page for each image. Thanks for your help in advance. |