Forums

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

Home Forums JavaScript Noob problem with jQuery: Element height jumps when content fadeOut <-> fadeIn

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #31653
    Arde
    Participant

    How to get rid of this jumping effect?

    Here is the code:





    jQuery Proplem












    #59987
    soap
    Participant

    Do you have a live example?

    #59991
    Arde
    Participant
    #60001
    soap
    Participant

    Why don’t you try this? I have no way of testing it right now.


    $('.nav-link1').click(function() {
    $('.link3').fadeOut('fast');
    $('.link2').fadeOut('fast');
    $('.link1').queue(function() {
    $(this).fadeIn(700);
    $(this).dequeue();
    });
    });

    Try that one and let me know how it works. I’ve never really dealth with queues much in this way so not sure.

    Or you could just set time intervals.

    #60002
    noahgelman
    Participant

    Its because you’re fading something in and out at the same time. So in the middle of the fade, you have 2 elements there, which is why you have the jump. It’s making room for both. What you need to do is fade out the old element THEN fade in the new element. You have to chain the fades one after the next instead of doing both at the same time.

    #60003
    noahgelman
    Participant

    It would be like:


    $('.nav-link1').click(function() {
    $('.link2, .link3').fadeOut(fast, function () {
    $('.link1').fadeIn(700);
    });
    });

    That should do it.

    #59962
    mslemeri
    Member

    Chris actually describes a solution in an unrelated video (starts at 26:30) to this issue in jQuery (which I have all the time).

    #59841
    Arde
    Participant

    @soap: It still behaves the same. You can see it in here: With Queue


    @noahgelman
    : Thanks for the explanation. I I tried your solution but It too behaves still the same. You can see it in here. With Chain


    @mslemeri
    : I didn’t understand 100% that solution in the video. Thanks for linking that one, it was really helpful and solved some other proplems for me.

    Still hoping to get this work somehow.

    #59836
    noahgelman
    Participant

    Hmm….. curious. It should work like how I wrote it.
    Although, for some reason you ahve a function inside a function for no reason. You should probably get rid of that.

    #59824
    Arde
    Participant

    @noahgelman: Could you be more specific what you mean by function inside a function? I’m a noob and just started to learn this jQuery witchcraft.

    #59792
    webarnes
    Member

    My first thought would be a css bug.
    Your call to css/style.css is not hitting a style sheet. (at least for me)
    Only local styles are present.

    Also You are utilizing HTML 5 elements without enabling them.
    I do not see any call to modernizer or html5 shiv.
    Very well could cause a visual tick.

    Just for the heck of it change
    background: none repeat scroll 0 0 #000000;

    to:
    background: #000;

    Regards,
    William

    #58960
    Arde
    Participant

    I finally fixed this tiny proplem. jQuery part where ok in the first place, just added separate ul for every link class and gave them a fixed position.

    Thanks to everyone for your comments :)

    Here are the fixed parts:



    This added to css

    .link1, .link2, .link3 {position: fixed; right: 40px;}
Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.