Placed in: Home arrow Programming arrow Webdesign arrow jFancyTile: A jQuery tile shifting image viewer plugin
jFancyTile: A jQuery tile shifting image viewer plugin

Previous week, colleague Willem and I were checking out the mosaic slideshow created by Martin. We were both impressed by his example, but wanted to take it to another level. We discussed on how we could add some features and how it should look like. Willem tranformed this idea to Silverlight and I created an easy to use jQuery plugin that does the same.

This jQuery plugin called jFancyTile is a tile shifting image viewer. It allows you to tranform any list with images to a beautiful tile shifting photo presenter.

jFancyTile: A jQuery tile shifting image viewer plugin

Check out the demo to see the plugin live. It's very customizable to fit your own needs. Read the rest of this article to see how this plugin works "under the hood".

Demo jFancyTile   Download jFancyTile

Take note this plugin is pretty CPU intense and works best when a low rowCount and columnCount is used on relatively small images. Experiment and use with caution. The Silverlight version from Willem doesn't have this problem.

Video Demonstration

Here's a video example on how the plugin works on Google Chrome.

How to use

Make sure your HTML looks like the following:

 
<div id="selector">
   <ul>
      <li><img src="images/img01.jpg" alt="Title 01" /></li>
      <li><img src="images/img02.jpg" alt="Title 02" /></li>
      <!-- More images -->
   </ul>
</div>

The alt attribute from each image will be used to display as the title on top.

Next, include the needed CSS and jQuery files to your HTML head:

 
<head>
   <link rel="stylesheet" type="text/css" href="css/jfancytile.css"/>
   <script type="text/javascript" src="js/jquery.jfancytile.js"></script>
 
</head>

Now you're ready to use the plugin! Feel free to change the CSS file to your needs. To use the default options, simply call the plugin on the selector:

 
$("#selector").jfancytile();

For more customization, you can change the following input variables (shown are the defaults):

 
$("#selector").jfancytile({
    inEasing: "swing",    // Easing animation of tiles flying IN
    outEasing: "swing",   // Easing animation of tiles flying OUT
    inSpeed: 1000,        // Animation speed of tiles flying IN
    outSpeed: 1000,       // Animation speed of tiles flying OUT
    rowCount: 8,          // Total number of rows
    columnCount: 13,      // Total number of columns
    maxTileShift: 3       // Max amount of positions a tile can shift
});

That's all there is to it! You can use the jQuery Easing Plugin for more variations of inEasing and outEasing.

How it works

Now for the most interesting part: How does this plugin actually work?

  1. Step 1 - Analyze all the images, get their alt attribute, dimensions and src.
  2. Step 2 - Create a container by using the biggest image dimensions.
  3. Step 3 - Remove the list from the HTML.
  4. Step 4 - Create the navigation buttons and apply them to the container.
  5. Step 5 - Calculate the number of tiles we need to create based on the rowCount and columnCount.
  6. Step 6 - Create the tiles by creating a div for each tile.
  7. Step 7 - Set the background-image for each tile using the image supplied. Use background-position to shift the image to the correct position.
  8. Step 8 - Append the title to the collection of tiles.
  9. Step 9 - Add functionality to animate the tiles to a random position and fade out.
  10. Step 10 - Add functionality to animate the tiles to their desired position and fade in.

I think the most interesting step is Step 7, so here's a reference image (zoomed in) for just that step. We assume each tile has a width of 64px (which is calculated by the script). The background-image source is the one loaded from the HTML.

Reference Image

Known issues

  • This is a pretty CPU heavy plugin - when you have too many rows or too many columns, the browser will crash. Like I said in the start of this article, use these parameters with caution. The Silverlight version from Willem is better for the CPU.
  • Sometimes, the images couldn't properly be loaded and the tiles will be really small. A refresh of the page will make it work again, but it's pretty annoying.
  • Chrome and Safari act a little bit differently when displaying the animation when compared to Firefox. When all images have been displayed in Chrome/Safari, the animation is correct.

Conclusion and Download

Besides these downsides of the script, I think it's a great jQuery plugin that could be implemented on websites as you like. What do you think?

Demo jFancyTile   Download jFancyTile

Script can always be improved - feel free to dig in the source code and make any changes necessary!


Tags:  jfancytile jquery plugin image viewer

Interested in this topic? You might enjoy another article I've written called

Did you like this article? Subscribe to my feed or email to keep updated on new articles.

Spread the word and submit to:
Digg!Reddit!Del.icio.us!Facebook!Technorati!StumbleUpon!Newsvine!Furl!Ma.gnolia!
Comments
Add NewSearchRSS
Design Informer - Cool!   2010-03-22 08:26:54
Gravatar image That's a pretty neat effect. The only thing is it lags a bit for me, but other than that, I really think it's great.

Good job Marco!
Marco - Yup   2010-03-22 12:22:58
Gravatar image Thanks mate! Yeah - that's the CPU usage I was talking about in the article. Depending on how busy your PC is, the animation is smoother etc.

Thanks for the kind words!
Gopal Raju   2010-03-22 08:27:53
Gravatar image I can see that flash is gonna die soon! ;)
Marco - True!   2010-03-22 12:23:42
Gravatar image Haha, yup! These kind of demos are some true Flash killers. Yet, Flash would be less heavy on the CPU since it can handle animations better than JavaScript.
Lam Nguyen - great   2010-03-22 08:36:13
Gravatar image Great effect, but it has problem with the CPU usage! I saw it's very slow! Maybe it's cuz of my computer :D. Anyway, great plugin you have here!
Marco - Indeed   2010-03-22 12:24:26
Gravatar image Yes, indeed. Depending on your workstation, browser and open applications, the animations are pretty hard to see. Anyway, thanks for your comment!
Rob - Amazing!   2010-03-22 08:55:55
Gravatar image I love this! It just shows how creative people can be!

It didn't seem too slow for me, but I do have a rather speedy set up.
Marco - Same here   2010-03-22 12:25:04
Gravatar image Yup, same here. Do have to admit that the animations are better in Chrome/Safari than in Firefox, but they still work pretty well. Thanks for sharing your thoughts!
Yoosuf - Superb plugin   2010-03-22 09:18:32
Gravatar image superb work dude, keep up the cool works :)

http://eyoosuf.com
Janko   2010-03-22 09:53:34
Gravatar image This looks very nice Marco
Martin   2010-03-22 10:44:07
Gravatar image Wow it looks great! Glad that my experiment inspired you guys to make the plugin. Hopefully when the new generation of browsers (and JavaScript engines) gets broader adoption, more people can enjoy jQuery animations.
Marco - Super!   2010-03-22 12:27:37
Gravatar image Actually, I made the plugin for jQuery and Willem transferred the idea to a Silverlight component :P . Chrome/Safari are better at handling the JavaScript compared to FF, but that will probably be smoother in the future. Hopefully will IE9's engine be powerful enough to display the animations even better! Thanks for your original idea and comment!
Smashing Share   2010-03-22 11:11:24
Gravatar image woww..nice one... jQuery, i love it but not getting time to learn it :)
Marco - You should!   2010-03-22 12:28:02
Gravatar image You really should - you'll love it ;) !
Hidayat Sagita   2010-03-22 11:16:19
Gravatar image Great plugin and great technique!
Marco - Thanks!   2010-03-22 12:29:58
Gravatar image @Janko & @Hidayat:
Thanks for those kind words - really appreciate it. Enjoy the plugin!
Richie - Mind Blowing   2010-03-22 18:02:17
Gravatar image Your jQuery tutorials are just blowing me away.... These are the stuff which really bring the essence of 'design' in the web world... keep it up, Marco.... I cant wait for more of such awesome stuff :D
Destiya Dian - Nice   2010-03-23 04:18:02
Gravatar image This is really nice plugin..

Good job marco..
Kelpie - Auto-Run Option?   2010-03-23 10:45:12
Gravatar image Hi,

I'm new to javascript and jQuery

Is there any way to get the plug-in to run automatically from image to image without the need for back and forward arrows?
Romeo   2010-03-24 14:19:13
Gravatar image Great Work Marco,
i like the plugini and in the future im sure your gonna make it work better :)
As other say i see no need in using flash at sites anymore when you can do all the thing with JavaScript.(jQuery).
What i really love is this plugin for jQuery -> http://www.spritely.net/
Its in the first steps but the thing you can do with sprites and jQuery are wonderfull :) i think flash will not die but it will be used as little as possible.

Thanks
Jack - Mr   2010-03-25 06:02:39
Gravatar image awesome, thanks for the share. cool effect.
Pascal   2010-04-05 13:48:04
Gravatar image Wow, nice effect, but i think it would be better done in canvas
that wouldn't suffer from the heavy dom creation and the resulting memory and cpu problems
Mickey - Errm...   2010-07-06 09:07:30
Gravatar image It's a bit slow because after I hit the arrow button there is a delay...

maybe have LOADING... after you click the arrow until it fully loads, maybe....

Though it is pretty cool :woohoo:
Read more...
Name:
Email:
  Gravatar enabled.
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Security Image
Please input the anti-spam code that you can read in the image.
Unsubscribe from e-mail notifications.
 
< Prev   Next >
Subscribe

About 5407 others will follow everything on Marcofolio.net.