Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I just add a queue because the #wait dialog may still be animated. Then I do this, but there are two problems:

  • expanding from 69px to 100% doesn't work (i mean: isn't smooth, it's bing bang no animation);
  • I'm pretty sure there may be a way of avoiding children().children():

Any idea?

  $('#wait').queue(function() {
    $('#tableau')
      .fadeIn(100)
      .queue(function() {
        $('tr').mouseenter(function() {
          $(this).children('.principal').children('.texte')
            .animate({ height: '100%'}, 'slow'); 
        }); 
        $('tr').mouseleave(function() {
          $(this).children('.principal').children('.texte')
            .animate({ height: '69px'}, 'slow', function() { $(this).clearQueue(); } );
        }); 
      }   
    );  
  }); 

Thank you!

share|improve this question

2 Answers

up vote 2 down vote accepted

You could try the jQuery closest() method and avoid going through multiple child elements.

share|improve this answer

animation

It seems you are doing the animation with 1ms (?), which would explain the jump. Have you tried using slow instead of 1?

$(this).children('.principal').children('.texte').animate({ height: '100%'}, 'slow'); 

children

As for the .children(), you are looking for .find():

$(this).find('.principal .texte').animate({ height: '100%'}, 1);
share|improve this answer
Yes I've tried. I've solved this problem in a tricky (and ugly way): I'm first showing everything expanded, then fill an array with the height in pixels for each row, then use this value in the function mouseenter() instead of "100%". (mouseleave works perfectly with a smooth animation) It works, but it's ugly, the comments I've left are longer than the code itself... – Olivier Pons Oct 28 '11 at 14:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.