Hey James,

Thanks for the advice. That's close, but not quite there. It does now
pull the height from the correct image, but there's a noticeable delay
that I've got to get around.

See example here: http://wilsonmcguire.com/eebuild/index.php?/work

Click on some of the options on the right, and you'll see the new
image fade in, and then jump down into place. Any way to have the CSS
change prior to the image loading in?

Marcus

On Oct 5, 3:03 pm, James <james.gp....@gmail.com> wrote:
> Try putting that part in fadeIn's second parameter, a callback
> function that executes after the fadeIn is completed:
>
>         $("#list .item a").click(function() {
>                 var imgPath = $(this).attr("href");
>                 $("#left p img").hide().attr({ src: imgPath })
>                     .fadeIn(600, function() {
>                         var workImgHigh = $("#work #left p img").height
> ();
>                         $("#work #left p").css({"height":workImgHigh
> +"px","margin-top":"-"+workImgHigh/2+"px","top":"50%"});
>                 });
>                 return false;
>         });
>
> On Oct 5, 7:29 am, "poundcommapo...@gmail.com"
>
> <poundcommapo...@gmail.com> wrote:
> > Hi.
>
> > I have written a quick function to change the src attribute of an
> > image. I also need to set some CSS properties on that image's parent
> > to get it to stay centered in the containing div. Here is the code
> > I've written.
>
> >         $("#list .item a").click(function() {
> >                 var imgPath = $(this).attr("href");
> >                 $("#left p img").hide().attr({ src: imgPath }).fadeIn(600);
> >                 var workImgHigh = $("#work #left p img").height();
> >                 $("#work #left p").css({"height":workImgHigh+"px","margin-
> > top":"-"+workImgHigh/2+"px","top":"50%"});
> >                 return false;
> >         });
>
> > The problem is that variable workImgHigh is getting set on the height
> > of the original image in that spot, _before_ the src changes.
>
> > How can I modify this to have the variable grab the height of the
> > incoming image?
>
> > Thanks much,
> > Marcus

Reply via email to