Hi, there— I'm hoping someone can help suss out what I'm doing wrong. I have a page that has 2 blocks of content with a couple of <li> elements to toggle between the two, like tabs. I'm using TimelineLite to show the first block, and—when toggling to the other block—TweenMax to hide the first block's elements and TimelineLite to transition in the second block's. What happens is page loads, first block appears. Toggle to 2nd block. 1st block is hidden, 2nd block appears. When I toggle back, 2nd block is hidden, 1st block appears BUT proceeds to disappear; it doesn't stay visible. The parent, #section0 is set visibility: hidden in the css and I'm using TimelineLite and TweenMax to do the hiding/revealing of the children only. For simplicity sake, I'll show only TimelineLite's first element being tweened.
var tl0 = new TimelineLite();
tl0.to($('#section0 h2'), 1.2, {autoAlpha: 1, ease:Power2.easeOut});
//then my click handler:
$('#subNav').on('click', 'li:not(.selected)', function() {
$('#subNav li').removeClass('selected');
$(this).addClass('selected');
var idx = $('#subNav li.selected').index();
switch(idx) {
case 0:
//hide block 2, then show block 1
TweenMax.to($('#section1 h2'), 0, {autoAlpha: 0, overwrite:'all'});
var tlA = new TimelineLite();
tlA.to($('#section0 h2'), 1.2, {autoAlpha: 1, ease:Power2.easeOut});
//Block 1 then disappears.
break;
case 1:
//hide block 1, then show block 2
TweenMax.to($('#section0 h2'), 0, {autoAlpha: 0, overwrite:'all'});
var tlB = new TimelineLite();
tlB.to($('#section1 h2'), 1.2, {autoAlpha: 1, ease:Power2.easeOut});
break;
default:
break;
}
});
Thank you in advance! —Victor