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

              
                <header>
  <p>ScrollMagic Parallax Example</p>
</header>

<!-- Includes can be found in settings -->

<section id="parallax1" style="background-image: url(http://deghq.com/yapp/front-labs/codepen-assets/slide-1.jpg);" class="parallaxParent">
</section>

<section class="spacer">
  <div>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium tempora quasi iste facere placeat corporis commodi. Accusantium esse hic dolore assumenda facere libero, in repellat distinctio commodi blanditiis, quas, culpa?</p>
    <button class="toggleIndicators">Hide Indicators</button>
  </div>
</section>

<section id="parallax2" class="parallaxParent" style="background-image: url(http://deghq.com/yapp/front-labs/codepen-assets/slide-2.jpg);">
</section>

<section class="spacer">
  <div>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. In deserunt voluptate soluta architecto, quam et rerum cum temporibus enim, neque, quo ipsum error recusandae debitis nobis quibusdam perferendis dignissimos dolores!</p>
    <button class="toggleIndicators">Hide Indicators</button>
  </div>
</section>

<section id="parallax3" class="parallaxParent" style="background-image: url(http://deghq.com/yapp/front-labs/codepen-assets/slide-3.jpg);">
</section>

<section class="spacer">
  <div>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. In deserunt voluptate soluta architecto, quam et rerum cum temporibus enim, neque, quo ipsum error recusandae debitis nobis quibusdam perferendis dignissimos dolores!</p>
    <button class="toggleIndicators">Hide Indicators</button>
  </div>
</section>

<footer>
  &copy; :P
</footer>
              
            
!

CSS

              
                header {
  width: 100%;
  height: 40vh;
  display: flex;
  align-items: center;
}

header p {
  margin: 0 auto;
  font-size: 5vh;
}

.parallaxParent {
  height: 600px;
  background-repeat: no-repeat;
  background-size: 200%;
  background-position: center -200px;
}

.spacer {
  padding: 200px 5vh 200px 5vh;
  max-width: 100%;
  margin: 0 auto;
  min-height: 600px; 
}

.spacer p {
  font-size: 3vh;
  margin-top: 200px;
}

button {
  padding: 10px;
  border-radius: 5px;
  width: 120px;
  height: 60px;
  display: block;
  margin: 0 auto;
}

footer {
  width: 100%;
  height: 200px;
  text-align: center;
}
              
            
!

JS

              
                // init controller
var controller = new ScrollMagic.Controller({
  globalSceneOptions: {
    triggerHook: "onEnter",
    duration: "200%"
  }
});

var scene1 = new ScrollMagic.Scene({
  triggerElement: "#parallax1"
});
scene1.setTween(new TweenMax($("#parallax1"), 1, {
  backgroundPosition: "center 200px",
  ease: Linear.easeNone
}));
scene1.addIndicators();
scene1.addTo(controller);

var scene2 = new ScrollMagic.Scene({
  triggerElement: "#parallax2"
});
scene2.setTween(new TweenMax($("#parallax2"), 1, {
  backgroundPosition: "center 200px",
  ease: Linear.easeNone
}));
scene2.addIndicators();
scene2.addTo(controller);

var scene3 = new ScrollMagic.Scene({
  triggerElement: "#parallax3"
});
scene3.setTween(new TweenMax($("#parallax3"), 1, {
  backgroundPosition: "center 200px",
  ease: Linear.easeNone
}));
scene3.addIndicators();
scene3.addTo(controller);

indicatorsShown = true;

$(".toggleIndicators").click(function(event) {
  if (indicatorsShown) {
    indicatorsShown = false;
    $(".toggleIndicators").text("Show Indicators");
    scene1.removeIndicators();
    scene2.removeIndicators();
    scene3.removeIndicators();
  } else {
    indicatorsShown = true;
    $(".toggleIndicators").text("Hide Indicators");
    scene1.addIndicators();
    scene2.addIndicators();
    scene3.addIndicators();
  }
});
              
            
!
999px

Console