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

              
                <div id="scrollDist"></div>
<div id="container">

 <svg id="map" width="1600" height="2000">
   
     <path id="line" fill="none" stroke="#585858" stroke-width="10" d="M 800 110 s288.523 489.332-421.266 549.777c-159.465 13.58-259.244-150.702-12.996-312.581C608.837 185.319 1369.43 246.785 1401.36 400.336c23.58 113.423-425.531 264.483-236.338 331.51 209.038 74.059 285.398 52.835 25.989 162.851-215.318 91.318 189.649 315.633-232.993 218.873-465.853-106.65-966.347-173.973-389.023 82.94 152.938 68.06 143.091 231.48-126.902 171-200.503-44.91-266.694 223.06 157.51 230.63 424.204 7.57 892.777-71.96 600.947 86.02-291.833 157.99-753.396-16.49-765.979 57.1-12.584 73.59 58.611 112.07 350 250"/>
  <path id="path" fill="none" stroke="#6f6f6f" stroke-width="5" d="M 800 110 s288.523 489.332-421.266 549.777c-159.465 13.58-259.244-150.702-12.996-312.581C608.837 185.319 1369.43 246.785 1401.36 400.336c23.58 113.423-425.531 264.483-236.338 331.51 209.038 74.059 285.398 52.835 25.989 162.851-215.318 91.318 189.649 315.633-232.993 218.873-465.853-106.65-966.347-173.973-389.023 82.94 152.938 68.06 143.091 231.48-126.902 171-200.503-44.91-266.694 223.06 157.51 230.63 424.204 7.57 892.777-71.96 600.947 86.02-291.833 157.99-753.396-16.49-765.979 57.1-12.584 73.59 58.611 112.07 350 250"/>
   
   <circle id="" cx="800" cy="110" fill="none" stroke="none" r="15" />
   
   <path id="point" fill="green" stroke="none" d="M821.767 105.048c0-5.546-4.503-10.05-10.05-10.05h-24.531c-5.547 0-10.05 4.504-10.05 10.05l20.367 30.516c5.547 0 24.264-30.516 24.264-30.516z"/>
   
   <text class="start" x="615" y="115">START</text>
   <text class="stop" x="80" y="600">ONE</text>
   <text class="stop" x="1420" y="420">TWO</text>
   <text class="stop" x="1380" y="820">THREE</text>
   <text class="stop" x="150" y="1050">FOUR</text>
   <text class="stop" x="690" y="1380">FIVE</text>
   <text class="stop" x="1320" y="1620">SIX</text>
   <text class="stop last" x="820" y="2020">DONE</text>
   
 </svg>
  
</div>

<div class="warningButton">Warning issue!</div>

<div class="warning">
  <p>Be careful with such animations. Inexperienced users could be irritated if the scroll position suddenly changes without their involvement.
  </p>
</div>
              
            
!

CSS

              
                html, body {
  width:100%;
  height:100vh;
  background:grey;
  margin:0;
}
#container{
  visibility:hidden;
}
#map{
  position:absolute;
  top:100px;
  overflow:visible;  
}
text{
  font-size: 50px;
  font-family: sans-serif;
  font-weight: 600;
  color: #585858;
}


.warningButton{
  position: fixed;
  right: 15px;
  bottom: 10px;
  color: #8e0303;
  cursor:pointer;
}
.warning {
  position: fixed;
  top:50%;
  left:50%;
  width:60%;
  height:40vh;
  padding: 20px 30px;
  background-color:green;
  visibility:hidden;
}
.warning p{
  font-size: 24px;
  font-family: sans-serif;
  color: beige;
}

              
            
!

JS

              
                console.clear();

// set initial states

var ww = window.innerWidth,
    wh = window.innerHeight,
    // special definition of 'total duration'
    // of the ScrollTrigger animation
    speed = 25,
    scrollDist = wh * speed,
    scrollEnd = wh * (speed -1),
    map = document.getElementById('map'),
    mapWidth = map.getBoundingClientRect().width,
    mapHeight = map.getBoundingClientRect().height;
   
gsap.set('#point', {rotation:-37, transformOrigin:'center'})

gsap.set('#scrollDist', {width:'100%', height:scrollDist})

gsap.set('#container', {
  position:'fixed', 
  width:mapWidth, 
  height:mapHeight,
  left:'50%',  
  top:0,
  xPercent:-50, 
  autoAlpha:1})

// == based on duration of timeline = 1 sec 
var snapV =     [0, 0.130, 0.310, 0.395, 0.565, 0.630, 0.820, 1],
    staggerV =  [   0.125, 0.305, 0.390, 0.560, 0.625, 0.815, 0.98];

//tween the svg path + pointer + stops by ScrollTrigger SNAP
gsap.timeline({
  defaults:{duration:1, ease:'none'}, 
  onComplete:final,
  scrollTrigger:{
    trigger:'#scrollDist', 
    start:'top top', 
    end:'+=' + scrollEnd, 
    scrub:0.3,
    snap: {
      snapTo: snapV,
      duration: {min: 0.1, max: 0.5},
      delay: 0.2,
      ease: "none"  
      },
    //  info for position = progress
    onUpdate: ({progress}) => {
    console.log(progress)
    }
  }
}) 
  .to('#point', {motionPath:{
    path: "#path",
    align: "#path",
    alignOrigin: [0.5, 0.5],
    autoRotate: -90
  },},0)
  .from('#path', {drawSVG:'0 0'},0) // , 0.0045
  .from('.stop',{
  autoAlpha:0, y:'-=100',
  duration:0.005,
  stagger: function(index, target, list) {
    return staggerV[index];
  }
},0)

function final(){
  gsap.to('.last', {scale:2, duration:1, repeat:1, yoyo:true})
}



//move container to follow circle
let povDelay = 1, // 1 = no delay
    pos = { x:-mapWidth/2, y:-mapHeight/2 },
    //pos = { x:-800, y:-450 },
    xSet = gsap.quickSetter('#container', "x", "px"),
    ySet = gsap.quickSetter('#container', "y", "px");

gsap.ticker.add(() => {  
  pos.x += (-gsap.getProperty('#point', 'x') - pos.x) * povDelay;
  pos.y += (-gsap.getProperty('#point', 'y') - pos.y) * povDelay;
  xSet(pos.x);
  ySet(pos.y);
});

// ==================

gsap.set('.warning', {xPercent:-50, yPercent:-50, autoAlpha:1})

var warning = gsap.timeline({paused:true})
.from(".warning", {autoAlpha:0, duration:0.5, ease:'power2.inOut'})

document.querySelector(".warningButton").addEventListener("mouseenter", () => warning.play(0));

document.querySelector(".warningButton").addEventListener("mouseleave", () => warning.reverse());

              
            
!
999px

Console