It may seem that Elastic CSS Framework only works for laying out websites, but there is more. In this Article ill show you how to build a simple Gallery Widget with elastic, we will call it elastic_gallery.
Now the layout

gallery desired design
This creates all the basic markup of the gallery, and now the CSS
.elastic-gallery .thumbnail
{
float:left;
padding:1px;
}
.elastic-gallery .image
{
position:absolute;
top:0;
left:0;
width:100%;
}
.elastic-gallery .thumbnails-display-container
{
overflow : hidden;
}
this simple rules prepares the code for the JavaScript effects to take place in the gallery, images will fade in, and thumbnails will have a slider effect
jQuery(function($){
$('.elastic-gallery').each(function(){
var gallery = this;
$('.right', this).click(function(){
$('.thumbnails-display-container', gallery).animate({
'scrollLeft' : ( $('.thumbnails-display-container', gallery).attr('scrollLeft') + $('.thumbnails-display-container', gallery).width() )
}, 500, 'linear');
});
$('.left', this).click(function(){
$('.thumbnails-display-container', gallery).animate({
'scrollLeft' : ( $('.thumbnails-display-container', gallery).attr('scrollLeft') - $('.thumbnails-display-container', gallery).width() )
}, 500, 'linear');
});
var imagesWidth = 0;
$('.thumbnail', this).each(function(){
imagesWidth += $(this).outerWidth(true);
});
$('.thumbnails', this).css('width', imagesWidth);
$('.thumbnail a', this).bind('click', function(event){
var img = new Image();
$(img).load(function(){
var current = $('.image', gallery);
var next = current.clone(true);
next.hide();
next.find('img').attr('src', img.src);
$('.image-container', gallery).append(next);
next.fadeIn(500, function(){
current.remove();
});
}).error(function(){
alert('error');
}).attr('src', $(this).attr('href'));
event.preventDefault();
});
});
});
At the end you obtain an elastic gallery, that you can even modify on the runtime, and using Elastic.refresh() on the context of the gallery will update the design of your gallery
first row, first column contentfirst row, second column contentfirst row, third column contentsecond row, second column content
Demo?
I know i have been missing the demo for this article, you will get it tomorrow, i promise.
There is now a demo in the repository for this gallery widget, though is not as elaborate in CSS as presented here on the image.
go to to documentation/demos/gallery
@
The link you provided “documentation/demos/gallery” is not valid!
and your search bar is broken
thanks for pointing that out we will try to fix it
demo? please?
i know we don’t have a link here but if you download from github you will get to see a gallery and a slider made with elastic.
http://github.com/azendal/elastic
there is a documentation folder, there a lot of cool elastic tricks in there.
Demo please!