Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <header role="banner">
  <nav class="anchor-nav" role="navigation">
    <a href="#section-1" id="anchor1">Section 1</a>
    <a href="#section-2" id="anchor2">Section 2</a>
    <a href="#section-3" id="anchor3">Section 3</a>
    <a href="#section-4" id="anchor4">Section 4</a>
  </nav>
</header>

<main class="full-screen" role="main">
  
  <section class="full-screen blue" id="section-1">
     <img  class="title" src="https://daks2k3a4ib2z.cloudfront.net/597b56c58d2f010001d8bedb/59b81aa33e0c400001eeb8dc_170909_Muuaaa-Arsenal_Alcapurria-Quema_Coasters.png" alt="">
  </section>

  <section class="full-screen orange" id="section-2">
    <img src="http://accountbased.co.uk/SAP/00684/john-deere/images/img1.jpg" alt="" class="animated-items">
    
  </section>

  <section class="full-screen red" id="section-3">
    <div>
      <p>Section Dos</p>
    </div>
  </section>

  <section class="full-screen blue" id="section-4">
    <div>
      <p>Section Tres</p>
    </div>
  </section>
</main>
              
            
!

CSS

              
                /*
	Demo Styles: NOT REQUIRED
*/
html,
body {
  margin: 0;
  height: 100%
}

a {
  color: white;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}
a.active {
  color: #000;
  text-decoration: underline;
}

h1,
p {
  margin: 0;
  padding: 0;
}

header {
  position: fixed;
  top: 10px;
  left: 10px;
}

section {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #EFEFEF;
}

.full-screen {
  display: flex;
  width:500vw;
  max-width:calc(1920px *3 );
  max-height:100%;
  overflow:hidden;
  height: 100%; /* makes panels the entire window height */
}
.title{
  width:  750px;
  height: 502px;
  position: relative;
  z-index: 2; 
  border:2px solid orange;
  box-shadow: -23px 25px 54px 2px rgba(0, 0, 0, 0.24);
}
.animated-items{
  width:  750px;
  height: 502px;
  position: relative;
  z-index: 2; 
  border:2px solid orange;
  box-shadow: -23px 25px 54px 2px rgba(0, 0, 0, 0.24);
  transform:translate3d(-100%, 0, 0);
}

.blue {
	background-color: #3883d8;
}
.red {
	background-color: #cf3535;
}
.orange {
	background-color: #ea6300;
}
              
            
!

JS

              
                console.clear();

// Init controller
var controller = new ScrollMagic.Controller({
  globalSceneOptions: {
    duration: $('section').height(),
    triggerHook: .025,
    reverse: true
  },
  vertical: false
});
 
var scenes = {
 
  'scene1': {
    'section-1': 'anchor1'
  },
  'scene2': {
    'section-2': 'anchor2'
  },
  'scene3': {
    'section-3': 'anchor3'
  },
  'scene4': {
    'section-4': 'anchor4'
  }
  
}

for(var key in scenes) {
  // skip loop if the property is from prototype
  if (!scenes.hasOwnProperty(key)) continue;

  var obj = scenes[key];

  var scene = new ScrollMagic.Scene({triggerElement: "#section-1", duration: 200, triggerHook: "onLeave"})
        .addTo(controller);   
  
  for (var prop in obj) {
    // skip loop if the property is from prototype
    if(!obj.hasOwnProperty(prop)) continue;

    new ScrollMagic.Scene({ triggerElement: '#' + prop })
    
        .setClassToggle('#' + obj[prop], 'active')
        .addTo(controller);
    
 
    new ScrollMagic.Scene({triggerElement: "#section-1", duration:  $('#section-1').outerWidth(true)}) 
      .setTween(".title", {x: "28.5%", scale: 1,  ease: Linear.easeNone})
      .addIndicators()
      .addTo(controller)
      .tweenChanges(false);
    
    new ScrollMagic.Scene({triggerElement: "#section-1", duration:  $('#section-1').outerWidth(true)})
        .on("enter", function(){
        $("#anchor1").addClass('selected');
        $("#section-1").addClass('animated fadeInUp')
       
      })
        .on("leave", function(){
        $("#anchor1").removeClass('selected');
        $("#section-1").removeClass('animated fadeInUp');
      })
      .addTo(controller);
    
    
    
    
//--------------
//SECTION-2 -- IMAGE SHOULD GO TO CENTER ON SECTION 2
//--------------   
    new ScrollMagic.Scene({triggerElement: "#section-2",offset: -350, duration:  $('#section-2').outerWidth(true)})
        .on("enter", function(){
        $("#anchor2").addClass('selected');
        $("#section-2").addClass('animated fadeInUp'); 

        var tl = new TimelineLite();

        tl.to("#section-2.fadeInUp .animated-items", 1, { x: getMidX("#section-2.fadeInUp .animated-items")+20 } );

        function getMidX( obj ){
          return ( $(obj).parent().width()/2 ) - $(obj).width()/2;
        }

      })
        .on("leave", function(){
        $("#anchor2").removeClass('selected');
        $("#section-2").removeClass('animated fadeInUp');

        tl.to("#section-2.fadeInUp .animated-items", 1, { x: getMidX("#section-2.fadeInUp .animated-items")+20 } );

        function getMidX( obj ){
          return ( $(obj).parent().width()/2 ) - $(obj).width()/2;
        }

      })
      .addTo(controller);
  
    
    
    
    
  }
}







// Change behaviour of controller
// to animate scroll instead of jump
controller.scrollTo(function(target) {

  TweenMax.to(window, 0.5, {
    scrollTo : {
      x : target,
      autoKill : true // Allow scroll position to change outside itself
    },
    ease : Cubic.easeInOut
  });

});


//  Bind scroll to anchor links using Vanilla JavaScript
var anchor_nav = document.querySelector('.anchor-nav');

anchor_nav.addEventListener('click', function(e) {
  var target = e.target,
      id     = target.getAttribute('href');

  if(id !== null && id.length > 0) {
    e.preventDefault();
    controller.scrollTo(id);

    if(window.history && window.history.pushState) {
      history.pushState("", document.title, id);
    }
  }
});

window.addEventListener("wheel", onWheel);

function onWheel(event) {
  event.preventDefault();

  var normalized;  
  var delta = event.wheelDelta;
  var scroll = (window.pageXOffset || document.scrollLeft) - (document.clientLeft || 0) || 0;
  
  if (delta) {
    normalized = (delta % 120) == 0 ? delta / 120 : delta / 12;
  } else {
    delta = event.deltaY || event.detail || 0;
    normalized = -(delta % 3 ? delta * 10 : delta / 3);
  }

  TweenLite.to(window, 2, {scrollTo: {x: scroll + 200 * normalized } });
}


              
            
!
999px

Console