Update: Version 1.1 released 2/8/08. Good bug fixes + Opera compatibility!
...so I fought back the charging Guanaco, immediately hopped on my paraglider, and basically caught the first flight out of Chile — but not without dealing with some cantankerous customs inspectors while drinking a cool glass of chicha. Really sorry it took so long! But hey, two years later, it's finally done!
Smooth Javascript Image Zooming For Your Web Pages
This much-requested chunk of Javascript to zoom images inline, originally written for this blog but later rolled out to the Panic website and used for screenshots, is now polished up, bug-fixed, available for you to use on your website!Designed to view full-size photos and images inline without requiring a separate web page load, FancyZoom's raison d’être (French for "raisin-determination") is providing a smooth, clean, truly Mac-like effect, almost like it's a function of Safari itself. Since I originally wrote this script, there are now a lot of image zoomers to choose from (including a similar effect now on Apple's own site!), such as the popular (and inspiring) Lightbox. So you might be asking: "Cabel, why use FancyZoom?" Well, here's why!
- Focused on the smoothest, most polished zooming animation possible
- Automatically scales images from any image link, with no HTML changes
- Preloads full-size images in the background on link mouseover
- No resource-heavy Javascript libraries — 100% coded from scratch to zoom
- Draws a nice drop shadow under the full-size image to offset it from the page
- Uses Safari 3's "box-shadow" feature to draw the drop shadow natively, no images required
- Requires only two new lines of code in your HTML
- Tested and works with Safari, Firefox, IE7, and IE6. (Looks better in modern browsers.)
Since FancyZoom is so easy to add to a web page, I encourage you to give it a try!
Instructions
Installing FancyZoom on your web pages should be dead simple.1 Download the FancyZoom package, right here:
2 Using Transmit (or your favorite FTP client), upload the two folders inside the package to the root of your webserver.
3Add the following two lines of code to the <head> section at the top of your web page(s):
<script src="/js-global/FancyZoom.js" type="text/javascript"></script>
<script src="/js-global/FancyZoomHTML.js" type="text/javascript"></script>
<script src="/js-global/FancyZoomHTML.js" type="text/javascript"></script>
4Add onload="setupZoom()" inside your page's existing <body> tag. For example:
<body id="whatever" [...] onload="setupZoom()">
5Whoah. You're done! The rest is automatic — links to images in your page will automatically zoom the images. For example:
<a href="image.jpg"><img src="image-thumbnail.jpg" /></a> will zoom up image.jpg when clicked.
Additional Details
There are a few extra notes that you might find useful.Want to add a caption? Add a title tag in your href. That's it!
FancyZoom will use the size of the first element in the href to determine the initial size and location of the zoom.
FancyZoom works best if you wrap your href around a thumbnail, but also works from text-only links to images.
FancyZoom will attach itself to any jpg, gif, png, bmp, or tiff link in your page.
If you're a Javascript hacker, FancyZoom's flexible fadeIn and fadeOut functions can be used for all sorts of fun stuff.
If you explicitly don't want an image to zoom, add a rel="nozoom" tag to your href.
Example
It's both an example, and some random pictures from Macworld Expo 2008!Release Notes
Version 1.1 released 2/8/2008.- Improved Opera compatibility
- Fixed an issue that would cause crazy infinite zooming
- Now returns alt-clicks and command-clicks back to the browser, for standard behavior (open in new tab, etc.)
License
FancyZoom is totally free for your non-commercial website.In a bit of an experiment: if your website is commercial (i.e. makes you money), you can license FancyZoom for $39 per site, a one-time fee. Instantly add nice image zooming to your site. Click here to instantly and securely buy a license.
Enjoy
I hope you and your websites enjoy FancyZoom. If you make any cool changes or improvements, let me know! And if you have awesome feedback, or find weird bugs, drop word in the comments.PS: Yes, you can even hold shift when you click an image. The Apple tradition continues!
56 Comments:
Worked like a charm:
http://tff4.com/work.php
I am on the latest FF Win.
on 1st time load of the page with new images, clicking the image brings up a small white box with the close X on the top right hand side.
You need to close this and then open it again to get the image to display, u need to do this for all images the 1st time u load them on all computers running firefox. tested in safari and worked 1st time. seems to just be FF related. any idea on a fix?
Thanks!
Now can you put a form in the popup?
If not, will this be a feature in the future?
Very good!
I would like to have this script function like the 'quick look' feature in Leopard. Is there a way to load different content into the window, and have it play a movie?
I absolutely love what you have accomplished thus far.
Thanks
Ive seen a few lightbox and iframe mixes but none with the zoom feature of this wonderful script.
thanks
Lee
Any ideas?
Firefox3 - works fast and easy :)
IE7 - works but the zoom is verrrryyy slow. IE7 on your page is fine and fast. Same code and parameters, same file sizes... what could be different?
Please help and thanks!
PS. Jollibee rocks! To those you don't know, they're a popular(at least in the Philippines) Filipino fast food franchise and I think everyone needs to try them out at least once.
How to installing FancyZoom in ".PHP"?
ThankS!!!!!!!!!!!!!!!!!!
I have a problem to get it work.
I made a little exemple of a site just to see how it works on my computer - to later integrate this feature in my website. But it doesn't work. I'm seeking for hours the solution.
Could you be able to look to the code and tell me where is a problem. The image opens like a normal "href" i dont know why...
code:
...
...
script src="/js-global/FancyZoom.js" type="text/javascript">
script src="/js-global/FancyZoomHTML.js" type="text/javascript">
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
title>Untitled Document /title>
style type="text/css">
/style>
/head>
body onLoad="setupZoom();">
img src="image1.jpg" width="181" height="135" border="0" />
/body>
/html>
All files are in one folder on my computer, i thought perhaps it works only on the server...
Thanks for an response, Maris
script src="js-global/FancyZoom.js" type="text/javascript">
script src="js-global/FancyZoomHTML.js" type="text/javascript">
Works fine on my blog (http://www.mediageci.tk) with my main browsers under Windows XP. I only have problems with the loading animation routine under the latest browsers. It only works under Opera (9.50 B10063), and shows the static first frame under SeaMonkey (1.1.11), Firefox (3.0.1) and Internet Explorer (7.0.5730.13).
And I have an additional feature idea, if you plan to improve it in the future. You could zoom the thumbnail until one point (would be uglier, more pixelated) while you crossfade it to the target. It would be interesting on some sites like my blog. (I imitate a monochrome paper with my thumbnails, and sometimes crop pieces from the full picture.)
Just stopped by to thank you for this wonderful image previewer. Thanks a million!
Just one question if I may...
How can I make this thing work locally, so I can test it whenever I do some changes in my HTML file, without uploading it to my server every single time ?
Sorry for my ignorance and thanks for your answer in advance.
"...I think if you try without the Slash at the start of the url it will be done.
script src="js-global/FancyZoom.js" type="text/javascript">
script src="js-global/FancyZoomHTML.js" type="text/javascript">
..."
It works, except it's not showing png images for close button and caption background. I guess path for those is defined somewhere inside those .js files but I am not sure how to fix this...
Any help would be greatly appreciated.
Thanks!
Yes, it was inside the FancyZoom.js file. This is the line that needs to be edited:
var zoomImagesURI = '/images-global/zoom/'; // Location of the zoom and shadow images
Just remove the very first slash before "images". Your line should look like this:
var zoomImagesURI = 'images-global/zoom/'; // Location of the zoom and shadow images
I just have a little request:
why don't you put the possibility to switch between more than one image with some arrows?
It would be the perfection made zoom! ;-)
Tnx,
Marco.
Regards
I'd made my website slideshow (media link) with ajax. It works perfectly until i refres my images on the slideshow (dinamicaly with ajax, not reloading the page...). The problem is that the new images aren't detected for the fancybox and the effect doesn't work...
Can someone help me?
Thank you!
I was wondering if there is a possibility to had a overlay when the picture zooms in? I know others do it, but I had some troubles making my site working woth the others scripts, and this one works perfectly, the only thing I´m missing it´s the overlay.
Can someone post how I can acheive this... if possible.
Thanks, Luis Monteiro
Just wondering if it's possible to place the pop up window somewhere other than center? In some instances it would be nice to have the pop up zoom left of the thumbnail rather than in the middle of the page.
Thanks.
www.endlessvows.org/packages.html
and we wanted to use just links or text for the images.......thanks
http://wordpress.org/support/topic/157370
Great bit of coding and im hoping to use it on my page.
I have one problem, trying to integrate the effect into an iweb page..
I have the actual zoom effect working perfectly but as soon as I link it into the page it removes every shadow and stroke-border from the page it is on!
I know they are still there, because if i unlink the zoomer by removing the bit of code in the head section of the page, everything comes back..
Any idea whats going on here?
thanks,
Chris
Further to my other comment it seems to be something to do with no longer using the pages CSS sheet but instead the zooms one!
Anyone know how the two can coexist in the same page?
Chris
Post a Comment