Home arrow HTML arrow Page 2 - Handling Images in a 3D Table Image Gallery
HTML

Handling Images in a 3D Table Image Gallery


Welcome to the second part of a three-part article on building an image gallery in a 3D HTML table. With an image gallery, it is natural that viewers may want to maximize certain images for closer examination, and then restore them to their original size. This article will show you how to add this feature and others to your gallery.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
February 09, 2009
TABLE OF CONTENTS:
  1. · Handling Images in a 3D Table Image Gallery
  2. · Functions
  3. · Image Resolution
  4. · Automatically Changing Images in a 3D HTML Table Gallery
  5. · Operation from the Programmer’s Point of View

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Handling Images in a 3D Table Image Gallery - Functions
(Page 2 of 5 )


The maximizeFn(ID) function

This is the “maximizeFn(ID)” function:


function maximizeFn(ID)

{

document.getElementById(ID).style.position="absolute";

document.getElementById(ID).style.zIndex="2";

document.getElementById(ID).style.width="400";

document.getElementById(ID).style.height="400";

document.getElementById(ID).title="Click to Restore";

maximized = true;

}


In our example, the restored image size is 100px X 100px, while the maximized image size is 400px X 400px.

When the maximizeFn(ID) function is called, it gives the image the CSS absolute position property. Next, it gives the image a CSS z-index value of 2. Then it gives the new width, and then the new height of the image. These are the dimensions when maximized (400px X 400px).

After it does this, it changes the title attribute of the image to (Click to Restore). While the image is maximized, if your mouse pointer goes over it, a tool tip should indicate “Click to Restore.” When the image is maximized, it can only be restored. So the function sets the maximized variable to true. When next the maxRest(ID) is called, it will use the maximized value of true to call the “restoreFn(ID)” function.

The restoreFn(ID) function

This is the “restoreFn(ID) function:


function restoreFn(ID)

{

document.getElementById(ID).style.position="relative";

document.getElementById(ID).style.zIndex="1";

document.getElementById(ID).style.width="100";

document.getElementById(ID).style.height="100";

document.getElementById(ID).title="Click to Maximize";

maximized = false;

}


When the restoreFn(ID)function is called, it gives the image the CSS relative position property. Next it gives the image a CSS z-index value of 1. After that, it gives the old width and then the old height of the image. These are the dimensions when restored (100px X 100px). It then changes the title attribute of the image to (Click to Maximize). While the image is restored, if your mouse pointer goes over it a tool tip should indicate “Click to Maximize.” When the image is restored, it can only be maximized. So the function sets the maximized variable to false. When the maxRest(ID) is next called, it will use the maximized value of false to call the “maximizeFn(ID)” function.

All of the functions use the ID of the image in their execution.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials