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

              
                
<svg id="svg" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 600 1200">
  <path class="line01 line" d="M 10 200  600 200" ></path>
  <path class="line02 line" d="M 10 400  600 400" ></path>
  <path class="line03 line" d="M 10 600  600 600" ></path>
  <path class="line04 line" d="M 10 800  600 800" ></path>
  <path class="line05 line" d="M 10 1000  600 1000" ></path>
  <text class="text01" x="30" y="190">2017</text>
  <text class="text02" x="30" y="390">2018</text>
  <text class="text03" x="30" y="590">2019</text>

  <path class="theGreenLine" 
        d="M -5,0
           Q 450 230 300 450 
           T 130 750
           Q 100 850 300 1000
           T 150 1200"
        fill="none" stroke="green" stroke-width="10px" />
  
  <circle class="ball ball01" cx="25" cy="25"></circle>
  <circle class="ball ball02" cx="298" cy="221"></circle>
  <circle class="ball ball03" cx="347" cy="419"></circle>
  <circle class="ball ball04" cx="223" cy="621"></circle>

</svg>



              
            
!

CSS

              
                
body {
  margin:0;
	width: 100%;
	height: 3000px;
  background:grey;
}

svg{
  position:absolute;
  width:600px;
  top:60vh;
  overflow:visible;
}

.ball{
  fill:darkgreen;
  visibility:hidden;
  r:20;
}

.line{
  fill: none;
  stroke: green;
  stroke-width: 2px;
}
text{
  fill:darkgreen;
  font-size:15px;
  font-family:sans-serif;
  visibility:hidden;
}
              
            
!

JS

              
                 
console.clear();

gsap.registerPlugin(MotionPathPlugin);

gsap.set(".ball", {xPercent: -50, yPercent: -50, transformOrigin: "50% 50%"});

var Elastic = 'elastic.out(2.5, 1)';

var action = gsap.timeline({defaults:{ease:"none"}})
.to(".ball01", {autoAlpha:1, duration:0.01})
.from(".theGreenLine", {drawSVG:0, duration:1},0)
.to(".ball01", {duration:1,  motionPath:{path: ".theGreenLine"}},0)
.to(".ball02, .text01", {autoAlpha:1, scale:2, transformOrigin:'center', ease:Elastic, duration:0.05},0.19) // start = scene progress
.to(".ball03, .text02", {autoAlpha:1, scale:2, transformOrigin:'center', ease:Elastic, duration:0.05},0.31)
.to(".ball04, .text03", {autoAlpha:1, scale:2, transformOrigin:'center', ease:Elastic, duration:0.05},0.48)



var Controller = new ScrollMagic.Controller();

var scene = new ScrollMagic.Scene({
  triggerElement: "#svg",
  duration:1200,  
  triggerHook: 0.5, // mid of viewport
})
.setTween(action)
//.addIndicators()
.addTo(Controller)

// ===== helper to time BALL, TEXT ================

scene.on("progress", function (event) {
    console.log("Scene progress: " + event.progress);
});


              
            
!
999px

Console