Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery won’t animate or expand

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #45023
    chrisburton
    Participant

    I’m having a hard time trying to get this to animate and expand. Any help?

    http://codepen.io/chrisburton/pen/lsdtc

    #136459
    Anonymous
    Inactive
    #136460
    pixelgrid
    Participant

    the effect you are trying to achieve is if the user hovers a font the whole div disappears and only the selected font is vissible?

    #136462
    chrisburton
    Participant

    @Jarolin No.

    Basically the `.gallery` has a fixed height due to the designed layout. I’m trying to expand the height by adding `overflow: visible;` and `height: auto;` to show the additional typefaces.

    If it’s also possible with a jQuery like slideDown in CSS, I’d opt for that.

    #136465
    CrocoDillon
    Participant

    You can’t animate to auto height I think, you can use the height of the inner element:

    $(‘.font-samples’).mouseenter(function() {
    $(‘.gallery’).animate({
    height: $(‘.list-item’).height() + ‘px’
    });
    });

    #136466
    chrisburton
    Participant

    @CrocoDillon Perfect! What about on `mouseleave`? I need it to go back to the default state.

    #136477
    CrocoDillon
    Participant

    With jQuery’s hover you can set both handlers:

    $(…).hover(function() {
    // enter
    }, function() {
    // leave
    });

    just put the original height back :)

    #136496
    chrisburton
    Participant

    @Crocodillon Thank you, sir!

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.