A highly customizable gallery/showcase plugin for jQuery.
Features
- Choose effect, should the image slide in, or fade in?
- Show fifth image by adding
#ad-image4
to the url, this takes precedence over oversettings.start_at_index
- jQuery call returns gallery instances, which enables you to change settings on the fly like the "Change to fade effect" link above
- Keyboard arrows to move back and forth
- Click on the edge of the big image to go to the next/previous
- Images are preloaded, and if the aren't finished loading when they are supposed to be displayed, a loading image will appear
- Slideshow count down only begins when the image has loaded and is visible
- Image title, can either be set in the title attribute, or in
elm.data('ad-title', 'My title here')
. $.data takes precedence over the title attribute - Image descriptions, can either be set in the longdesc attribute, or in
elm.data('ad-desc', 'My description here')
. $.data takes precedence over the longdesc attribute - Callbacks on different events that has access to the internal object, which means that you can access all internal methods, etc
- Takes the dimensions of the image container div and scales down images that are larger than it
- Image is positioned in the middle if it's smaller than the container div
- Images that are larger than the container are scaled down to fit inside the container
Browser compatibility
The script has currently been tested in Firefox 3/Win, Firefox 3.5/Mac, IE6+7+8/Win, Chrome 2/Win, Safari 3/Win, Safari 4/Mac, Opera 9/Win, Opera 9/Mac. If you have seen it working correctly in some other browser, or on some other platform, please let me know.
Browsershots »
When checked at browsershots.org Konqueror 4.2 and 3.5 on Debian Testing behaved really strange. IE 5.5 on Windows 2000 seems to cause some Javascript error. I tested it by setting the gallery to start at image 9, and made sure it displayed that image and that the thumbs scrolled to thumb 9. So the test isn't exactly complete, since all features aren't tested.
Browsers where the plugin seems to work fine from browsershots are:
- SeaMonkey 1.1.9 Fedora 7
- Opera 10.00 Ubuntu 8.04 LTS
- Epiphany 2.22 Ubuntu 8.04 LTS
- Shiretoko 3.5 Debian Testing
- Opera 9.64 Debian Testing
- Firefox 3.1 Debian Testing
- Firefox 2.0.0.19 Ubuntu 8.04 LTS
- Firefox 3.0.10 Windows XP
- MSIE 7.0 Windows XP
- Safari 4.0 Windows XP
- SeaMonkey 1.1.14 Windows XP
- Opera 8.54 Windows XP
- Firefox 3.5 Windows XP
- SeaMonkey 2.0 Windows XP
- Shiretoko 3.5 Windows XP
- Firefox 3.0 Fedora 7
- Safari 3.2.1 Windows XP
- Chrome 2.0.172.33 Windows XP
- Opera 9.64 Windows XP
- Opera 8.0 Windows XP
- MSIE 6.0 Windows XP
- Firefox 1.5.0.12 Windows XP
- Firefox 2.0.0.18 Windows XP
- MSIE 8.0 Windows XP
- Firefox 3.1 Windows XP
- SeaMonkey 2.0 Ubuntu 8.04 LTS
- Firefox 3.5 Ubuntu 8.04 LTS
- Firefox 1.5.0.13 Ubuntu 8.04 LTS
- Firefox 1.0.8 Ubuntu 8.04 LTS
- Firefox 3.5 Mac OS X 10.5
- Safari 4.0 Mac OS X 10.5
Downloads
Example code
Don't worry, all of these options are optional.
Javascript
var galleries = $('.ad-gallery').adGallery({
loader_image: 'loader.gif',
width: 600, // Width of the image, set to false and it will read the CSS width
height: 400, // Height of the image, set to false and it will read the CSS height
thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)
// Note that this effect combined with other effects might be resource intensive
// and make animations lag
start_at_index: 0, // Which image should be displayed at first? 0 is the first image
animate_first_image: false, // Should first image just be displayed, or animated in?
animation_speed: 400, // Which ever effect is used to switch images, how long should it take?
display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?
display_back_and_forward: true, // Are you allowed to scroll the thumb list?
scroll_jump: 0, // If 0, it jumps the width of the container
slideshow: {
enable: true,
autostart: true,
speed: 5000,
start_label: 'Start',
stop_label: 'Stop',
stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
countdown_prefix: '(', // Wrap around the countdown
countdown_sufix: ')',
onStart: function() {
// Do something wild when the slideshow starts
},
onStop: function() {
// Do something wild when the slideshow stops
}
},
effect: 'slide-hori', // or 'slide-vert', 'resize', 'fade', 'none' or false
enable_keyboard_move: true, // Move to next/previous image with keyboard arrows?
cycle: true, // If set to false, you can't go from the last image to the first, and vice versa
// All callbacks has the AdGallery objects as 'this' reference
callbacks: {
// Executes right after the internal init, can be used to choose which images
// you want to preload
init: function() {
// preloadAll uses recursion to preload each image right after one another
this.preloadAll();
// Or, just preload the first three
this.preloadImage(0);
this.preloadImage(1);
this.preloadImage(2);
},
// This gets fired right after the new_image is fully visible
afterImageVisible: function() {
// For example, preload the next image
var context = this;
this.loading(true);
this.preloadImage(this.current_index + 1,
function() {
// This function gets executed after the image has been loaded
context.loading(false);
}
);
// Want slide effect for every other image?
if(this.current_index % 2 == 0) {
this.settings.effect = 'slide';
} else {
this.settings.effect = 'fade';
}
},
// This gets fired right before old_image is about to go away, and new_image
// is about to come in
beforeImageVisible: function(new_image, old_image) {
// Do something wild!
}
}
});
// Set image description
some_img.data('ad-desc', 'This is my description!');
// Change effect on the fly
galleries[0].settings.effect = 'fade';
HTML
These are the only elements required for it to work. If you want, you can add all sorts of crazy elements inside those elements, but I would advice you not to put stuff into
.ad-image-wrapper
for the simple reason that it's emptied on start up.
Customize
You can alter the way it looks by editing the CSS file, or overriding the default CSS rules.
Image sizes
You probably want some other image size than the one in the demo above, and the only thing you need to do for this is to add this pice of CSS.
.ad-gallery {
width: YOUR-IMAGE-WIDTHpx;
}
.ad-gallery .ad-image-wrapper {
height: YOUR-IMAGE-HEIGHTpx;
}
Or you can specify it in the settings.width
and settings.height
. If you do that though, the gallery might flicker on page load, since it might take a while before that code runs, so I would suggest that you set it with CSS. If you want bigger thumbnails, the height of the thumb list adjusts itself to that, but you might want to position the arrows next to the list of your thumbs. You do that by adding this CSS and modifying to fit your needs.
.ad-gallery .ad-back {
left: -20px;
width: 13px;
background: url(your_back_button.png) no-repeat;
}
.ad-gallery .ad-forward {
right: -20px;
width: 13px;
background: url(your_forward_button.png) no-repeat;
}
Animations
You can now add your own animation, by doing something like this.
// The first argument is the name of your animation, which you then set in
// galleries[0].settings.effect
// The second argument is the function that handles the animation and it takes
// three arguments. The first is a jQuery object to the div that holds the image
// element and the image description element of the image that should be displayed
// The second is the direction, either 'left' or 'right'
// The third is the jQuery object that holds the description
// Your function should return an object like this:
// {old_image: {}, new_image: {}, speed: 100, easing: 'swing'}
// 'speed' and 'easing' are optional
// 'old_image' and 'new_image' are sent to the jQuery animate-method
// so use it just like you would use the $.animate-method
// This function gets executed with the gallery instance as its context
// so 'this' points to the gallery instance
galleries[0].addAnimation('wild',
function(img_container, direction, desc) {
var current_left = parseInt(img_container.css('left'), 10);
var current_top = parseInt(img_container.css('top'), 10);
if(direction == 'left') {
var old_image_left = '-'+ this.image_wrapper_width +'px';
img_container.css('left',this.image_wrapper_width +'px');
var old_image_top = '-'+ this.image_wrapper_height +'px';
img_container.css('top', this.image_wrapper_height +'px');
} else {
var old_image_left = this.image_wrapper_width +'px';
img_container.css('left','-'+ this.image_wrapper_width +'px');
var old_image_top = this.image_wrapper_height +'px';
img_container.css('top', '-'+ this.image_wrapper_height +'px');
};
if(desc) {
desc.css('bottom', '-'+ desc[0].offsetHeight +'px');
desc.animate({bottom: 0}, this.settings.animation_speed * 2);
};
img_container.css('opacity', 0);
return {old_image: {left: old_image_left, top: old_image_top, opacity: 0},
new_image: {left: current_left, top: current_top, opacity: 1},
easing: 'easeInBounce',
speed: 2500};
}
);
[Via coffeescripter]
0 comments to "Gallery plugin for jQuery"
Recent Posts
Search Medhley
Followers
Blog Archive
-
▼
2010
(85)
-
▼
June
(25)
- 45 Wonderful Website to Download Best Quality Free...
- Inspiring Ipad Wallpapers
- Find The Number Of Figures In This Illusions
- Famous Companys Attractive Logos
- More Than 100 Excellent Logos
- Free Smoke Effect Photoshop Brushes Sets Download
- How to Create a Stylish Sports Car Dashboard in I...
- New 3D Mobile Phone
- Create an Attractive Vector Butterfly in Illustrator
- Gallery plugin for jQuery
- Photoshop Tool Bar and it’s resident icons
- Browser of choice: web development 2010 survey res...
- Google Desktop Developer
- 6 Useful Photoshop CS5 tools with video explanation.
- Fabric Textures for Your Next Designs
- Learn Free Flash CS3 Tutorial Step 18 and 19
- Learn Free Flash CS3 Tutorial Step 16 and 17
- Learn Free Flash CS3 Tutorial Step 14 and 15
- Learn Free Flash CS3 Tutorial Step 12 and 13
- Learn Free Flash CS3 Tutorial Step 10 and 11
- Learn Free Flash CS3 Tutorial Step 8 and 9
- Learn Free Flash CS3 Tutorial Step 6 and 7
- Learn Free Flash CS3 Tutorial Step 4 and 5
- Learn Full Free Flash CS3 Tutorial Step 2 and 3
- Flash CS3 Tutorial
-
▼
June
(25)
Post a Comment