Home › Forums › JavaScript › Noob problem with jQuery: Element height jumps when content fadeOut <-> fadeIn
- This topic is empty.
-
AuthorPosts
-
February 16, 2011 at 12:10 pm #31653
Arde
ParticipantHow to get rid of this jumping effect?
Here is the code:
jQuery Proplem
February 16, 2011 at 12:16 pm #59987soap
ParticipantDo you have a live example?
February 16, 2011 at 12:46 pm #59991Arde
ParticipantFebruary 16, 2011 at 2:56 pm #60001soap
ParticipantWhy 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.
February 16, 2011 at 3:03 pm #60002noahgelman
ParticipantIts 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.
February 16, 2011 at 3:09 pm #60003noahgelman
ParticipantIt would be like:
$('.nav-link1').click(function() {
$('.link2, .link3').fadeOut(fast, function () {
$('.link1').fadeIn(700);
});
});That should do it.
February 16, 2011 at 4:10 pm #59962mslemeri
MemberChris actually describes a solution in an unrelated video (starts at 26:30) to this issue in jQuery (which I have all the time).
February 16, 2011 at 7:19 pm #59841Arde
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.
February 16, 2011 at 7:29 pm #59836noahgelman
ParticipantHmm….. 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.February 16, 2011 at 7:53 pm #59824Arde
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.
February 16, 2011 at 10:10 pm #59792webarnes
MemberMy 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,
WilliamFebruary 21, 2011 at 6:01 pm #58960Arde
ParticipantI 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;}
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.