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 -50 600 400">
  
  <text  x="10" y="0">
    Speed in relation to mousemove / position.</text>
  <text x="20" y="50">SLOW</text>
  <text x="560" y="50">FAST</text>
  
  <path stroke="black" d= "M 75 45 550 45"/>
  
  <path class="path motionPath" d="M 80 180 C 140 20 270 210 350 140 C 450 60 550 120 540 260 C 530 410 460 220 330 310 C 240 370 40 300 80 180"/>

  <circle id="hero" cx="80" cy="180" r="15" fill="#186718" stroke="none" />

  <circle class="point" cx="340" cy="145" r="10" fill="#186718" stroke="none" />
  <circle class="point" cx="300" cy="325" r="10" fill="#186718" stroke="none" />
  
</svg>
              
            
!

CSS

              
                body{
  margin:0;
  background-color:grey;
}

svg{
max-height:90vh;
width:90vw;
}
.path{
  fill:none;
  stroke:green;
  stroke-width:5;
}
.point{
  fill:"#186718";
}
text{
  font-family:sans-serif;
  font-weight: bold;
}
              
            
!

JS

              
                console.clear();

gsap.defaults({ overwrite: "auto"});

var points = gsap.utils.toArray('.point');
    

var action = gsap.timeline({
  defaults:{
    duration:1, ease:'none'}, 
  repeat:-1, timeScale:0.05
})
.to('#hero', {
  motionPath:{
    path: ".motionPath",
    align: ".motionPath",
    alignOrigin: [0.5, 0.5],
    autoRotate: true,
  }
})
.to(points[0], {
  attr:{r:20}, fill:'red',
  duration:0.1,
  repeat:1,yoyo:true,
}, 0.22)
.to(points[1], {
  attr:{r:20}, fill:'red',
  duration:0.1,
  repeat:1,yoyo:true,
}, 0.73)

const pos = { x: window.innerWidth};
const mouse = { x: pos.x, y: pos.y };

window.addEventListener("mousemove", e => {    
  speed = e.x / 1000 + 0.2;
  action.timeScale(speed)
  
  console.log(speed)
})
              
            
!
999px

Console