Question

For reference, the thing I need help with is located at:

http://www.photographeller.com/portfolio

What I'd like to do is when you click a portfolio section to open, before it opens have the images preload, then have the section expand and have the images fade into view, with maybe a loader image while the images are loading or something of that effect. Instead of how it is now, where the section opens and the images load abruptly. Then when the section is clicked closed, have the images fade out. Also if it's possible, have some easing on the section when it expands, but that's just me being nit picky.

The jquery code I have in place toggles the class that changes the width of the container of the images. The class applied also changes the display of the main image to none, and changes the display of the other images in the section from none to inline. And another bit of code, as supplied to me in my last question on stack overflow, that takes the combined width of all the images in the section clicked and applies to it's containing div. Here is the code I have for this effect:

<script type="text/javascript">

$(document).ready(function(){       
$(".boxgrid").click(function () {
$(this).toggleClass("openBoxgrid", 1000);

});

$('div.innerOpen').each(function() {
    var totalImageWidth = 0;

    $("img", this).each(function () {
      totalImageWidth += $(this).width();
    });

    $(this).width(totalImageWidth);
});

});

</script> 

I've tried a few things in the .click function for .boxgrid, like .fadeIn() on all images with the class of hidden, but it doesn't really work the way I'd like. And it also causes ALL images in every section with that class to appear, and not just the section that is clicked on.

Well, I apologize for the lengthy question. Any help on this would be greatly appreciated. Thank you!

Was it helpful?

Solution

The current problem is that you change the width before you fade in the images.

This starts to execute but it takes one second

$(this).toggleClass("openBoxgrid", 1000);

Mean while you change the width and that's instantaneous. Probably a better effect will be to have a div of the size of the first image, then a div the size of al the images inside.

Then animate to the with of the first to the size of the other, it will a smother effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top