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

              
                <svg viewBox="0 0 800 350">

  <path id="test" d="M 0 170 Q 50 30 210 160 C 280 220 270 180 300 90 C 320 30 420 50 390 110 C 310 260 480 240 490 150 C 500 50 630 40 600 130 C 540 290 760 10 800 150 " fill="none" stroke="#000" stroke-width="5"/>

  <text class="x" x="0" y="0">X</text>
  
</svg>
              
            
!

CSS

              
                
body{
  background-color:grey;
  margin:0;
  height:150vh;
}
text{
  font-size: 40px;
  font-family: sans-serif;
  fill: beige;
}
              
            
!

JS

              
                
//https://greensock.com/docs/v3/Plugins/MotionPathPlugin/static.getPositionOnPath()


// get the RawPath of the path "#test"
let rawPath = MotionPathPlugin.getRawPath("#test"),
    point;

// cache the measurements first 
// (only necessary once, unless the path data changes)
MotionPathPlugin.cacheRawPathMeasurements(rawPath);


gsap.timeline({
  scrollTrigger:{
    trigger: "svg",
    pin:true,
    scrub:true,
    start:"top top",
    end:"+=200vh",
    //  info for position = progress
    onUpdate: ({progress}) => {
      point = MotionPathPlugin.getPositionOnPath(rawPath, progress, true);
      console.log(point.x, point.y, point.angle, progress)
    }
  },
  defaults:{ease:'none'}
})
  .from("#test", {drawSVG:'0', duration:1},0)
  .to('.x', {attr:{x:400, y:233}, duration:0.2}, 0.4)


              
            
!
999px

Console