Jump to content
Search Community

rgrober

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by rgrober

  1. I think I've identified the problem, after implementing indicators and offsets as suggested above.

     

    Also, as @PointC mentioned:

    Quote

    Because you also have that contentsAnimation() timeline nested in your contentsBottom_tl timeline on line 16. The contentsBottom_tl  timeline is not in any ScrollMagic scenes so it fires on page load.

     

    So, in my code locally, I included contentsBottom_tl in a ScrollMagic scene.

     

    The actual problem seems to be that when I call contentsAnimation() in more than one timeline, it fires contentsAnimation() automatically on page load in all Magic Scroll scenes.

     

    This code causes contentsAnimation() to fire automatically on all parts of the page:

    function contentsAnimation(){
    	return new TimelineLite()
    		.fromTo([".contents__label", ".contents__label--green"], .4, {opacity:0, y:'+=25'}, {opacity:1, y:0})
    		.staggerFromTo("li.contents__chapter", 0.5, {opacity:0, x: '-=15'}, {opacity:1, x: 0}, 0.15, '-=.5');
    }
    
    var contentsHome_tl = new TimelineLite();
    contentsHome_tl
    	.add(contentsAnimation());
    
    var contentsChapter_tl = new TimelineLite();
    contentsChapter_tl
    	.add(contentsAnimation());
    
    var contentsBottom_tl = new TimelineLite();
    contentsBottom_tl
    	.add(contentsAnimation());

     

    This code (removing the other timelines that include contentsAnimation()) allows for the first instance of contentsAnimation() to load only when the Trigger is encountered (the behavior I want on another instance of contentsAnimation() lower on the page).:

    function contentsAnimation(){
    	return new TimelineLite()
    		.fromTo([".contents__label", ".contents__label--green"], .4, {opacity:0, y:'+=25'}, {opacity:1, y:0})
    		.staggerFromTo("li.contents__chapter", 0.5, {opacity:0, x: '-=15'}, {opacity:1, x: 0}, 0.15, '-=.5');
    }
    
    var contentsHome_tl = new TimelineLite();
    contentsHome_tl
    	.add(contentsAnimation());

     

    Is there another way to call contentsAnimation, in other timelines, so it doesn't fire automatically on page load and only fires when a specified trigger is encountered?

     

    Thank you again!!!

  2. @PointC The code doesn't work in either CodePen, or in my code locally, when this line is added:

     

    var controller = new ScrollMagic.Controller();

     

    Locally, I removed all other code from my javascript file until I found what was causing the issue, and it seems to be the above code. It only seems to affect the instance where I am trying to animate the same div in two different spots on the same page.

  3. @PointC thank you so much for having a look!

     

    I actually have ScrollMagic loaded on my site, but forgot to include it in my codePen!

     

    What's interesting is that it seems to be working in the codePen, but it's not working in my code. I must have duplicated something, or something is out of place in my code.

     

    I really, really appreciate your help.

  4. I'm sorry to bug everyone with this again, but I'm still encountering some issues.

     

    I actually have the same module in two different parts of the same page.

     

    This is my solution:

    function contentsAnimation(){
    	return new TimelineMax()
    		.from(".contents__label", .4, {opacity:0, y:'+=25'})
    		.staggerFrom("li.contents__chapter", 0.2, {opacity:0, x: '-=15'}, 0.15, '-=1.1');
    }
    
    var contentsHome_tl = new TimelineLite();
    contentsHome_tl
    	.add(contentsAnimation());
    
    var contentsChapter_tl = new TimelineLite();
    contentsChapter_tl
    	.add(contentsAnimation());
    
    var contentsBottom_tl = new TimelineLite();
    contentsBottom_tl
    	.add(contentsAnimation());

     

    I then .add the resulting timelines (contentsHome_tl, contentsChapter_tl, contentsBottom_tl) to different, parent timelines.

     

    However, I'm encountering some odd behavior, and I'm assuming I've done something wrong.

     

    Any further help you can provide is greatly appreciated. Thank you again.

     

×
×
  • Create New...