Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="hero-list-container">
            
    <section class="hero-story hero first-hero hero1 scrollMajicFix">
                
        <div class="module-background">
          <h1 class="text1">Scroll Down!</h1>
        </div>
                
    </section>
            
    <section class="hero-story hero second-hero hero2 scrollMajicFix">
                
        <div class="module-background">
          <h1 class="text2">Again...</h1>
        </div>
                
    </section>
            
    <section class="hero-story hero third-hero hero3 scrollMajicFix">
                
        <div class="module-background">
          <h1 class="text3">One more time.</h1>
        </div>
                
    </section>
</div>



<div class="content hero wht hero4">
            <h1 class="page">In order for the normal page content to animate to scroll position after the last slide the first element of the normal page content must be included in the selector 'hero' and have hero[index] i.e. 'hero4' class for the animation</h1>
</div>

  
        <div class="content">
          <h1 class="page">Remaining content no longer needs to to be included in selector</h1>
        </div>
        <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
        <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
         <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
         <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
         <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
              <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
        <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
        <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
        <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
         <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
         <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
         <div class="content">
          <h1 class="page">Page Content</h1>
        </div>
  

              
            
!

CSS

              
                * {
    margin: 0;
    padding: 0;
}

h1.page{color:black;text-align:center;padding-top:100px}

.scrollMajicFix{top:0 !important}

.hero-story, .scrollTo {
    width: 100%;
    height: 100vh;
    margin: 0 auto;
    position: relative;
}



.module-background {
    position:relative;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

.module-background h1 {
    position:absolute;
    color: white;
    left:50%;
    top: 90%;
    transform: translate(-50%);
    font-size:24;
}


.first-hero .module-background {
    background-color: green;
}

.second-hero .module-background {
    background-color: yellow;
}

.third-hero .module-background {
    background-color: orange;
}

.wht{background:white}
              
            
!

JS

              
                $(window).on('load', function () {
    
   TweenLite.to(".text1", 1, {fontSize:100,
   top:'20%',delay:.5,ease: Power4.easeOut}) 
    
    var ctrl = new ScrollMagic.Controller({
        globalSceneOptions: {
            
        }
    });
  

    // This each sets the pins
    
    $('.hero-story').each(function(index,element) {
       // set pin 
        new ScrollMagic.Scene({
            triggerHook: 'onLeave',
            triggerElement: this,
            duration:1 
          // giving a scene duration causes pins to push 
          // followers enabling normal scrolling for content
        })
        .setPin(this)
        .addTo(ctrl)
        
      
     }); //hero-story each 
      
     
    // This each sets the animation
  
    $('.hero').each(function(index,element) {  
      
        new ScrollMagic.Scene({
            triggerHook: 'onLeave',
            triggerElement: this,
            offset:-10 // small offset added to prevent overscrolling accidentally triggering
        })
        .on('leave', function (event) {
              TweenLite.to(window, 1, {scrollTo:{y:$(window).height() * (index-1),      
                                       autoKill:false},ease: Power4.easeOut})
           })
        .addTo(ctrl);  // scene end


        
       new ScrollMagic.Scene({
            triggerElement: this,
            triggerHook: 'onEnter',
            offset:10 // small offset added to prevent overscrolling accidentally triggering
        })
          .addTo(ctrl)
          .on('enter', function (event) {
                  console.log('triggered');
                  console.log(index+1);
                      console.log(event.scrollDirection);
                      TweenLite.to(window, 1, {scrollTo:{y:".hero" + (index+1),  
                          autoKill:false},ease: Power4.easeOut});
                      TweenLite.to(".text" + (index+1), 1, {fontSize:100,
                          top:'20%',delay:.5,ease: Power4.easeOut}) 
           }); // scene end
       
      
    }); //hero each
  
  }); //window onload
   



              
            
!
999px

Console