CJ Image Flipbox 1.1

A Nice jQuery Plug-In That Mimics Apple's iPhoto App to Display a Group of Images

JQuery Plug-In: CJ Image FlipBox v1.1.0

Apparently I'm a gluten for punishment, because I'm at it again. I done gone and made me another jQuery plug-in. CJ Image FlipBox v1.0 is a jQuery plug-in that displays a series of images based on the mouse position within the display box. The left-most side of the FlipBox displays the first image, where as the right-most side displays the last image. Moving between the two, displays any other images that fall between. This is an attempt to mimic Apple's iPhoto software and the way it displays events. As an added bonus, I actually took the time and tested it in the following browsers: FireFox 3.5, IE6, IE7, IE8, Safari 4. (Lesson learned from my first jQuery Plug-In!)

I made this plug-in initially for a few e-Commerce sites I'm working on. It's a nice way to display multiple images for a product, but I think it has other uses as well. I'll leave that up to you to discover on your own. So hit up the following download links and grab yourself a copy today!

Example Usage

I tried to keep things a simple as possible. Basically you just need to create one or more FlipBoxes that contain a series of images. The Plug-In can handle multiple FlipBoxes with any number of images inside. I would gather that the only real limit is the strain you will put on the user for downloading the page. (i.e. a lot of large images my take some time). All you need to do is create some <div> blocks that have some images within like this:

<div class="cj_image_flipbox_block">
    <div class="cj_image_flipbox_pics">
        <img src="my_image_01.jpg" alt="Image 1" width="180" height="240" /><br />
        <img src="my_image_02.jpg" alt="Image 2" width="180" height="240" /><br />
        <img src="my_image_03.jpg" alt="Image 3" width="180" height="240" /><br />
        <img src="my_image_04.jpg" alt="Image 4" width="180" height="240" /><br />
        <img src="my_image_05.jpg" alt="Image 5" width="180" height="240" />
    </div>
</div>

To initiate everything, you need to call the Image FlipBox plug-in like so:

$("div.cj_image_flipbox_block").cjImageFlipBox({});

The CSS is simple as well. There really only one element we need to style and that's the class cj_image_flipbox_block. The other div (cj_image_flipbox_pics) is used by the plug-in to find the images. I made it this way in case you wanted to add another element to the block (like a caption or title). Here's a basic example of the CSS I used on the demo page:

/*
   styles for cj image flipbox
----------------------------------*/
div.cj_image_flipbox { display: block; width: 100%; height: auto; }
div.cj_image_flipbox_block { position: relative; display: block; width: 180px; height: 240px; overflow: hidden; border: 2px solid #000; margin-right: 10px; margin-bottom: 10px; float: left; }
div.cj_image_flipbox_block br { display: none; }

That's about as simple as you can get, right? If you would like to see it in action, check out the demo page. And as always, if you have any problems or question, be sure to let me know. My sole reason for existance is to make you happy!

9 responses to "CJ Image Flipbox 1.1"

joe j
joe j says:
Hey I love the plugin! Such a cool feature for Apple fans! One question...is there any way to make the set of images snap back to the first image in the set? If so, that would save me!! Please help...thanks!

-Joe
Doug
Doug responds:
@joe j - Sure, all you would need to do is add a "mouseout" event to the script. Something like:

$(sys.elem).mouseout(function (e) {
var self = this;
$(self).find("div.cj_image_flipbox_pics img.cj_image_flipbox_img").attr({
"src": self.imgs[0].src
});
});

That should do the trick. You could either add this right after the $(sys.elem).mousemove block, or add the mouseout event to that block.

Hope this helps. Let me know if that's confusing.
joe j
joe j responds:
@Doug -

worked like a champ! Thanks...I just had to be very selective as to where to place the code...other than that thanks a ton!
Maarten
I wanted to use a lightbox together with this plugin, but because the plugin adds another entry in the html, the image group gets confused. So i made some small changes to the code which simplifies it and fixes the issues with the lightbox. Also fixed an issue with offsetLeft.
Can i send it somewhere if you wanna take a look at it?
Doug
Doug responds:
@Maarten - Just post the code in a comment, assuming you didn't change everything it should be easily posted.

I'll take a look at it, Thank!
Doug
Doug says:
For anyone having problems viewing the demo using IE. Try refreshing the iFrame content. It seems to be some kind of caching issue with IE. I'll try to look into further, but that should help you for now.
joe J
joe J says:
Doug,

It's me again, from a long time ago...I have your image flip box working great, but wanted to see if a few features were possible.

What I am trying to accomplish is to have a different hyperlink associated with each image that flips through. In some instances it works, but others it doesn't. Please help!

-Joe
Doug
Doug responds:
@joe J - You have someplace online I can take a look at what your doing?
outline4
hi, your skript is wonderful!
works out of the box.

but as soon as I try to center the wrapper within the page, things start to get buggy...

here's the demo:
http://www.zueriwest.ch/demo/flipbook_1/

as soon as I put margins and paddings to the wrapper it won't work...

do you know what could cause this?
thanks for sharing your plugins!
respect!

stefan
Doug
Doug responds:
@outline4 - Looks cool! What browser is it failing in? I just did a quick test in Safari and it looks normal.
aiz
aiz says:
While it works great on firefox and ie7, I`m experiencing problems on chrome... The site is not finished yet, but if you could take a look at http://www.exthema.com.ar/demos/poliarquia/ perhaps you can help me understand what`s wrong.
Regards... and thank you,
AiZ
Doug
Doug responds:
@aiz - MooTools! I think there is an issue using jQuery with MooTools. Try initializing the script this way:

$(function() {
   $(document).ready(function() {
      $("div.cj_image_flipbox_block").cjImageFlipBox({
         debug: false
      });
   });
});


try this way:

jQuery(document).ready(function($){
   $("div.cj_image_flipbox_block").cjImageFlipBox({
      debug: false
   });
});

Doug
Doug responds:
@Doug - p.s. I'm currently trying to convert all my projects to use "jQuery" instead of "$" which could possibly conflict with other JavaScript libraries.
AiZ
AiZ says:
Thanks Doug for the previous reply. I ended up dicarding Joomla for this project.

I was wondering if there was a parameter so once the mouse is not over the pictures, it goes back and shows the first one instead of keeping the latest picture showed.

Thanks!
AiZ
Doug
Doug responds:
@AiZ - haha, take a look at the first two comments.
jamesd
Hi, just wondering if it would be possible to modify this script to scroll through the image set by clicking on the image area and dragging vertically. I'm hoping to create CT scan teaching files, and this is the way CTs are usually viewed.
Doug
Doug responds:
@jamesd - You want them to "click and drag" and not just "mouseover and drag"? i.e. the images only cycle while the mouse is down? You can definitely modify it to do this, but the click while dragging kind of goes against the "spirit" of what this plug-in is supposed to mimic.
Debug
Debug says:
Hey Doug,
Great script. I'm just having a little trouble with the flipbox in a centred div. Turning on the debug I've noticed that the x and y values are relative to the entire page, rather than just the image. Do you know if there is a way for me to adjust this?
Here's an example of my problem.
Any help would be greatly appreciated.
http://flipbox.jamesjohnston.net/debug.html
Thanks
Doug
Doug responds:
@Debug - Hmmm... I'll take a look and see if I can see what's going on.
Doug
Doug responds:
@Debug - Yep, there was a problem with the way I was determining the offset. I'm working on uploading version 1.1.1. Should be online shortly.

Comments are closed.