Categories Archive Search Blogroll

Sandbox

Web Development Lab - Experiments, Plugins, Workarounds

DOWNLOAD DEMO

The plugin

This little jQuery image gallery plugin is basicly recreates the standard built-in window scrolling with a smooth easing effect. It is still in an early, development state, thus it may suffer from issues; but I will be working on it to make jReelGallery a more solid and robust widget.

The idea came while I was browsing the internet for available galleries for jQuery. I have seen a lot of good solutions but none of them fullfilles all the requirements I have been looking for. I decided to create a new plugin with all the features I need or consider as important: simplicity, usability and light-weight code.

Usability

Nowdays usability should be a very important and crucial part of a any web project. By extending the availability of your site and presenting it to wider audience, you increase the probability of achieving more visits which is leading to more sales, conversions and success.

In programming soemtimes it is really hard but not impossible at all to be light-weight and userfriendly at the same time. Sometimes you need to sacrifice a few things to stay between of the limits. This time the sacrifice was to give up the degradation when javascript is turned off. Whats left is a nice navigation: the plugin provides several ways to scan through the gallery. Mainly all the default(?) features, namely mouse scrolling, up and down arrow keys, home and end buttons, you would use while browsing in a window are available. In the future I would like to widen the “shortcuts” to include page down / up as well. Moreover, make it possible to configure it as you wish.

Usage

HTML

<ul id="jreel-gallery">
	<li><img src="images/1.jpg" alt="1.jpg" /></li>
	<li><img src="images/2.jpg" alt="2.jpg" /></li>
	<li><img src="images/3.jpg" alt="3.jpg" /></li>
</ul>

JavaScript

jQuery(document).ready(
	function(){
		$('#images').css('height',$(window).height()); /* I set the height by javascript to fill the full screen */
		$("ul#jreel-gallery").reelGallery();
	}
);

CSS

ul#jreel-gallery {
	width: 400px;
	height: 1px; /* In the example I set the height by javascript, see above */
	margin: 0 auto;
	padding: 0px 50px;
	overflow: hidden;
}

ul#jreel-gallery li {
	width: 400px;
	height: 300px; // Important! See below
	background: #fff;
	margin: 35px 0px;
	position: relative;
}
ul#jreel-gallery img {
		width: 400px;
		height: 300px; // Important! See below
	}

Note: I use precise dimensions for the images. It is not necessary to give the proper size of each and every image, but it comes with a price. The code itself contains an algorithm for this case that will calculate the all the heights by measuring the images. Problem is solves, or isn’t? No, because to calculate the proper size all the images, they have to be loaded before the algorithm is running. This means you need to use a preloader for your website or otherwise you are forced to give the dimensions by hand. It’s up to you. I suggest using a preloader.

In the demo I’m using a preloader, because I want to show the full potential of the plugin. I combined it the famous thickbox plugin and a PHP on-the-fly thumbnail generator.

Options

maxAcceleration : 20 Actually it’s a negative acceleration. This number is used when the gallery reaches the end or top. It slows down the easing. Higher number means smaller easing (= takes more time to stop).
speedFactor: 0.2 It’s the factor of the easing. Very sensitive. Try changing it to 0.1 for example.
framesPerSecundum: 33 How often should the code refresh in a second? Like speedFactor, changing it may require a fine tuning on other options (like speedFactor)
eventArea: ‘document’ Where the events should be triggered?
keyEvents: true Should the keyboard shortcuts (up, down, home, end) be enabled?
mouseEvents: true Should the mouse scrolling be enabled?

Sources

Posted on 9th Jul, 2010

JavaScript, jQuery

20 responses

Comments
  1. What license is this under?

    campuscodi   August 25, 2010 - 12:10 pm | Reply
    • Hi,
      The plugin is licenced under creative commons. You can modify, redistribute or whatever you want until you add the the source i.e. my website’s url to it.

      Marcell   August 27, 2010 - 11:32 am | Reply
  2. Any new versio for this jquery plugin?

    dyka   November 14, 2011 - 10:45 pm | Reply
    • Hi dyka,
      No, not yet. I’m quite busy with other stuff but I hope I will have some time in the near future to update. I might create a github repo too.

      Marcell   November 16, 2011 - 9:46 am | Reply
  3. Hello,

    Sorry for noob question, but I’m unable to use the gallery, because I get error .mosewheel is not a function.

    Any help?

    Insomnium   November 21, 2011 - 2:23 pm | Reply
  4. very noob question, but i’m know almost nothing about web sites.
    how to use this? :D i just want create small page for my photos.

    oleg   November 25, 2011 - 6:54 pm | Reply
  5. I’ll right away snatch your rss feed as I can’t to find your e-mail subscription link or newsletter service. Do you have any? Please permit me recognize in order that I could subscribe. Thanks.

    Amie Albrashi   December 4, 2011 - 12:29 am | Reply
    • Hey Amie, I don’t have a newsletter service unfortunately. Follow me on twitter if you wish to be updated. Thanks.

      Marcell   December 8, 2011 - 10:02 am | Reply
  6. Hi,
    You demo links don’t work :(

    Daniel   February 2, 2012 - 7:26 am | Reply
Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>