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

              
                

<main>
<svg id="oscar" viewBox="0 0 150 260" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="1.5" noscale>
  <path class="stroke oscar01" d="M -.5 78.546H10.41s6.353-21.99.432-40.119c-6.395 1.313-4.967-9.401.812-5.89-.412-7.34 17.435-16.33 29.157-4.784 4.541 4.473 3.635 14.046-3.542 15.161-14.002-1.844-13.02.363-7.739 4.941-2.265 8.953-3.849 17.836-3.165 26.485l9.999.276c8.349.811 4.908 3.443-10.326 4.01" fill="none" stroke="#000" stroke-width="1.13"/>
  <path class="stroke oscar02 hidden"  d="M -.5 78.546c.633.028 10.155 0 10.155 0s6.302-19.703.547-40.119c-6.395 1.313-4.967-9.401.812-5.89-.412-7.34 17.435-16.33 29.157-4.784 4.541 4.473 3.635 14.046-3.542 15.161-14.002-1.844-13.02.363-7.739 4.941-2.265 8.953-.461 17.836.223 26.485l9.999.276c8.348.811 4.907 3.443-10.326 4.01" fill="none" stroke="#000" stroke-width="1.13"/>
  <path class="stroke oscar03 hidden"  d="M-.5 78.546c1.208.006 13.565 0 13.565 0s6.614-27.177.122-40.119c-6.395 1.313-4.967-9.401.812-5.89-.413-7.34 17.435-16.33 29.156-4.784 4.541 4.473 3.636 14.046-3.541 15.161-14.003-1.844-13.02.363-7.739 4.941-2.265 8.953-3.096 17.836-2.412 26.485l9.999.276c8.441.236 5.296 4.099-10.157 3.93" fill="none" stroke="#000" stroke-width="1.13"/>
  <path class="stroke oscar04 hidden"  d="M-.5 78.546c1.208.006 14.086 0 14.086 0s6.614-27.177.122-40.119c-6.395 1.313-4.967-9.401.812-5.89-.413-7.34 17.435-16.33 29.156-4.784 4.541 4.473 3.636 14.046-3.541 15.161-18.305-6.81-16.626 10.906-7.822 7.466-2.265 8.953-3.013 15.311-2.329 23.96l9.999.276c8.441.236 4.915 3.362-10.318 3.93" fill="none" stroke="#000" stroke-width="1.13"/>

  <path class="stroke stroke02" d="M29.269 78.546s-39.525-2.973-12.195 43.954c12.516 21.491 43.099 1.433 22.117 32.781-18.575 27.751-26.583 62.038 24.933 33.944" fill="none" stroke="#000"/>
  <path class="stroke heart"d="M 64.282 188.966c2.715-3.015 9.553-8.008 10.235-13.886-.107-5.747-8.965-5.386-10.476 0-1.434-5.508-11.272-4.891-11.166 0 .118 5.483 8.415 11.263 11.407 13.886z" fill="none" stroke="#000"/>
  <path class="stroke stroke03" d="M64.226 188.867s21.428 12.016-11.441 23.805c-10.6 3.802-41.773-4.52-46.417 8.178-3.44 9.408 18.609 27.752 18.609 27.752" fill="none" stroke="#000"/>
  <path class="greenThumb" d="M61.514 244.454c1.001-2.247-.058-3.415-2.213-4.817-7.2-3.205 3.929-7.528 5.839-2.105.601 1.705-.696 4.153.332 6.493-2.057-1.294-3.958.429-3.958.429z" fill="green"/>
  <path class="stroke thumb"d="M24.976 248.591c5.745 6.769 31.826-.858 31.826-.858 3.415-.845 8.502-4.64 2.499-8.096-7.2-3.205 3.929-7.528 5.839-2.105.601 1.705-1.408 5.6.818 6.873 1.075-.675 1.87-.777 2.55-.579 1.986.579 1.551 2.462.048 2.737 3.143.352 1.848 2.735-.102 2.927 1.777-.105 2.184 1.761.302 2.214 0 0-2.124.756-4.485.015-3.42-1.075-27.424 5.861-36.632 4.528" fill="none" stroke="#000"/>
  <ellipse id="eye" cx="31.965" cy="31.416" rx="3.323" ry="2.178" fill="#4c4c4c"/>
  
  <text class="first lines hidden" x="50" y="45">You are scrolling.</text>
  <text class="first deco lines hidden" x="50" y="50">But I'm pinned!</text>
  <text class="was lines hidden" x="50" y="58">I was pinned!</text>

  <text class="test" x="20" y="115">Test it.</text>

  <text class="love" x="6" y="180">YOU will &nbsp &nbsp &nbsp &nbsp    it!</text>
  <text class="sure" x="17" y="240">SURE</text>
  
</svg>
    
    
  


  </main>

  <p class="green">powered by GSAP scrollTrigger © </p>



              
            
!

CSS

              
                body{
  margin:0;
  background:grey;
  height:100vh;
  overflow-x:hidden;
  background-image: linear-gradient( #777777b3 .1em, transparent .1em);
  background-size: 10em 10em;
  height:10000px;
}
.green{
  position: fixed;
  top: 0;
  right: 0;
  font-family: sans-serif;
  color: #595d59;
  font-weight: 600;
  padding: 5px;
  font-size: 10px;
}
#wrapper{
 visibility:hidden;
}

main{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

#oscar{
  position:relative;
  overflow: visible;
  visibility:hidden;
  width:1000px;
}

.stroke{
  fill: none;
  stroke: #505050;
  stroke-width:1;
}
.line{
  fill:none;
  stroke:#424242;
  stroke-width:5px;
}
.hidden{
  visibility:hidden;
}
text{
  font-size: 4px;
  fill: #615959;
  font-family: sans-serif;
}
.test{
  font-family: 'Fredericka the Great', cursive;
  font-size: 20px;
}
.love{
  font-family: 'Fredericka the Great', cursive;
  font-size: 10px;
}
.sure{
  font-family: 'Fredericka the Great', cursive;
  font-size: 13px;
}
section{
  position: relative;
  margin: 150px 20% 50px 20%;
  max-width: 600px;
  font-family: sans-serif;
  color: #353535;
}
section h1{
  font-size: 5vw;
  margin: 0;
}
section h2{
  font-size: 30px;
  margin: 70px 0 20px 0;
  visibility:hidden;
}
section p{
  font-size: 20px;
  margin: 50px 0 50px 0;
}


              
            
!

JS

              
                console.clear();

var oscar = document.querySelector("#oscar"),
    ww = window.innerWidth,
    wh = window.innerHeight;

console.log();

gsap.set(oscar, {autoAlpha:1})


// == scroll animation ====================
gsap.timeline({
  scrollTrigger: {
    trigger: '#oscar',
    pin:'main',
    scrub: 0.5,
    start: 'top top',
    end: '+=70%'
    },
  defaults:{ease:'none'}
  })
.from(".oscar01", {drawSVG: 0, duration: 3})
.set('.oscar01', {fill:'#6b6a6a'})
.from('#eye', {autoAlpha:0, duration:0.1})
.to(".oscar01", {morphSVG: '.oscar02', duration:1})
.to(".oscar01", {morphSVG: '.oscar03', duration:0.5})
.to(".oscar01", {morphSVG: '.oscar04', duration:1, repeat:7, yoyo:true},'talk')
.to('#eye', {x:'+=1', duration:1, repeat:7, yoyo:true},'talk')
.to('.first', {autoAlpha:1, duration:0.1, stagger:3}, 'talk+=1')

// == part 02 =====================
gsap.timeline({
  scrollTrigger: {
    trigger: '.stroke02',
    scrub: 0.2,
    start: '20% 10%',
    end: '+=1100px'
    },
  defaults:{ease:'none'}
  })
.set('.deco', {textDecoration:'line-through'})
.to('.was', {autoAlpha:1, fill: 'green', fontWeight:600})

.from(".stroke02", {drawSVG: 0, duration: 1.5})
.from(".heart", {drawSVG: 0, duration: 0.2})
.set(".heart", {fill:'green'})
.to(".heart", {rotation:-10, svgOrigin:'64.3 189', duration:0.2})
.from('.love', {autoAlpha:0, duration:0.1})
.to(".heart", {rotation:10, svgOrigin:'64.3 189', duration:0.2, repeat:3, yoyo:true}, 'thumb')
.from(".stroke03", {drawSVG: 0, duration: 1}, 'thumb')
//.to('main', {y:'+=400', duration:0.7}, 'thumb')
.from(".thumb", {drawSVG: 0, duration: 0.5}, 'thumb+=1')
.from('.sure', {autoAlpha:0, duration:0.1})
.from('.greenThumb',{autoAlpha:0, duration:0.01, repeat:4, yoyo:true, repeatDelay:0.1})

.to({}, {duration:2})

.to('main', {y:'-=400', duration:2}, 0)

// == actionTest ===========
ScrollTrigger.create({
  trigger: '.test',
  start: 'bottom 50%',
  end: 'bottom -20%',
  onEnter: () => actionTest.duration(1).play(),
  onLeave: () => actionTest.pause(0),
  onEnterBack: () => actionTest.duration(0.5).play(0),
  onLeaveBack: () => actionTest.pause(0)
});
                        
var actionTest = gsap.timeline({paused:true})
.from(".test", {x: 500, duration: 1})

              
            
!
999px

Console