Pen Settings



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


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


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.


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.


                <div style="height: 50vh; display: flexbox; align-items: center;">a</div>
<img src="" style="transform: scaleX(-1); width: 200px" id="rec"/>
<svg fill="none" xmlns="" viewBox="0 0 1000 1000">
  <path id="path" d="M0 100s269.931 86.612 520 0c250.069-86.612 480 0 480 0" stroke="black" stroke-width="1"/>


                body {
    width: 100%;
    height: 3000px;
    overflow-x: hidden;

#rec {
    position: absolute;
    background-color: white;
    width: 200px;



// The start and end positions in terms of the page scroll
const offsetFromTop = innerHeight * 0.25;
const offsetFromLeft = innerWidth * 0.25;
const pathBB = document.querySelector("#path").getBoundingClientRect();
const startY = - innerHeight + offsetFromTop;
const startX = pathBB.right - innerWidth + offsetFromLeft;
const finishDistance = startY + pathBB.height - offsetFromTop;
const finishDistanceX = startX + pathBB.width - offsetFromLeft;

// the animation to use
var tween ="#rec", {
  duration: 5, 
  paused: true,
  ease: "none",
  motionPath: {
    path: "#path",
    align: "#path",
    autoRotate: true,
    alignOrigin: [0.5, 0.5]

// Listen to the scroll event
document.addEventListener("scroll", function() {
  // Prevent the update from happening too often (throttle the scroll event)
  if (!requestId) {
    requestId = requestAnimationFrame(update);


function update() {
  // Update our animation
  tween.progress((scrollY - startX) / finishDistanceX);
  // Let the scroll event fire again
  requestId = null;