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

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.

HTML

              
                <div class="description panel blue">
  <div>
    
    
 <canvas id="hero-lightpass"></canvas>
  </div>
</div>


<section class="panel red">
  <h2>TWO: should scroll up, pushing one, pin for animations, then scroll up revealing three.</h2>
</section>
<section class="panel orange revealed">
	THREE: should be revealed, pin and play another AirPod-style movie.
</section>
<section class="panel purple">
	FOUR: should scroll over three, pin and play animation
</section>
<section class="panel green">
	FIVE: should scroll up, pushing four, pin and play animation
</section>
<section class="panel red">
	SIX: should scroll up, pushing five, pin and play another Airpod-style animation
</section>
<section class="panel orange">
	SEVEN: should scroll up and conceal six, pin and play animation
</section>
<section class="panel purple">
	EIGHT: should scroll up, pushing seven
</section>






              
            
!

CSS

              
                .revealed {
  position: abosulte;
  width: 100%;
  height: 100vh;
  z-index:1
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

// layered pinning

gsap.utils.toArray(".panel").forEach((panel, i) => {
  ScrollTrigger.create({
    trigger: panel,
    start: "top top", 
    pin: true, 
    pinSpacing: false 
  });
});

// panel blue airpods video code

const canvas = document.getElementById("hero-lightpass");
const context = canvas.getContext("2d");

canvas.width = 1158;
canvas.height = 770;

const frameCount = 147;
const currentFrame = index => (
  `https://www.apple.com/105/media/us/airpods-pro/2019/1299e2f5_9206_4470_b28e_08307a42f19b/anim/sequence/large/01-hero-lightpass/${(index + 1).toString().padStart(4, '0')}.jpg`
);

const images = []
const airpods = {
  frame: 0
};

for (let i = 0; i < frameCount; i++) {
  const img = new Image();
  img.src = currentFrame(i);
  images.push(img);
}


let airpodTL = gsap.timeline()
  .to(airpods, {frame: frameCount - 1, snap: "frame", onUpdate: render})


ScrollTrigger.create({
    animation: airpodTL,
    trigger: ".blue",
    scrub: 1,
    pin: true,
  })


images[0].onload = render;

function render() {
  context.clearRect(0, 0, canvas.width, canvas.height);
  context.drawImage(images[airpods.frame], 0, 0);
}


// panel red animation

let redTL = gsap.timeline()
  .from(".red h2", {opacity: 0, y:20})


ScrollTrigger.create({
    animation: redTL,
    trigger: ".red",
    scrub: 1,
    pin: true,
  })
              
            
!
999px

Console