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

              
                <body>
    <canvas id="goldenhemp-canvas"></canvas>
    <div class="bg">
        <div class="homepage">
            <div class="box-center">
              
              <div class="heading-main">Heading 1</div>
              <div class="tagline-main">
                Tagline
              </div>
            </div>
        </div> 
 
         <!--Added Logo to top left --> 
         <section class="section" data-startpercent="10.0" data-endpercent="30.0" data-starty="-25" data-endy="25">
            <div class="left-center-content">
                Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus minus
            dignissimos commodi harum voluptatem expedita a sit nam magni veniam
            officiis quaerat fuga dolorum asperiores nostrum, possimus, odit,
            ipsum tempore!
              </div>
         </section>
        
    
      <!--Added text 2-->
      <section class="section" data-startpercent="30.0" data-endpercent="50.0" data-starty="-25" data-endy="25">
        <div class="right-center-content">fffff
          <h3>Lorel Ipsum</h3>
        </div>
      </section>

      <section class="section"  data-startpercent="50.0" data-endpercent="60.0" data-starty="-25" data-endy="25">
        <div class="right-center-content">
          <h3>Get in Touch</h3>
          <p>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus minus
            dignissimos commodi harum voluptatem expedita a sit nam magni veniam
            officiis quaerat fuga dolorum asperiores nostrum, possimus, odit,
            ipsum tempore!
          </p>
          <a href="" class="button">Contact Us</a>
        </div>
      </section>
    </div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Montserrat&display=swap");
html,
body {
  font-family: 'Montserrat', sans-serif;
  color: #f2f1ec;
  background-color: #151515;
  margin: 0;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
html {
  height: 100%;
  width: 100%;
  /* overflow: hidden; */
}
.bg {
  height: 1000vh;
}
canvas {
  position: fixed;
  top: 0;
  width: 100%;
  object-fit: contain;
}
.homepage {
  position:relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;

}
.homepage .box-center {
  width: 75%;
  display: flex;
  align-items: center;
  flex-direction: column;
  z-index: 1;
}
.heading-main {
  z-index: 9999;
  margin: 0vmin 0 2vmin 0;
  font-size: 40px;
  font-style: normal;
  font-weight: normal;
  line-height: 49px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  word-wrap: break-word;
  flex-wrap: wrap;
  font-feature-settings: 'pnum'on, 'lnum'on, 'kern'off;
}
.tagline-main {
  z-index: 9999;
  text-align: center;
  word-wrap: break-word;
  flex-wrap: wrap;
  font-size: 20px;
  line-height: 24.38px;
}
.left-text-center {
  max-width: 431px;
  position: absolute;
  display: flex;
  align-items: center;
}
.logo {
  margin: 0vmin 0 2vmin 0;
  width: 100%;
  height: auto;
}

.section{
  position:relative;
  height:100vh;
  width: 100vw;
  display: flex;
  align-items: left;
  justify-content: center;
  flex-direction: column;
  z-index:9999;
}
.section .left-center-content {
  position:relative;
  height:100vh;
  left: 10%;
  font-size: 20px;
  font-weight: 400;
  line-height: 24.38px;
  width: 25%;
  align-items: center;
  text-align: center;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  
}
.section .right-center-content {
  position:relative;
  height:100vh;
  
  left: 65%;
  font-size: 20px;
  font-weight: 400;
  line-height: 24.38px;
  width: 25%;
  align-items: center;
  text-align: center;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  
}


.contact-us {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: left;
  justify-content: center;
  flex-direction: column;
}

.contact-us div.right-center-content {
  position: relative;
  left: 60%;
  font-size: 20px;
  font-weight: 400;
  line-height: 24.38px;
  width: 25%;
  align-items: center;
  text-align: justify;
  display: flex;
  flex-direction: column;
  z-index: 9999;

}

              
            
!

JS

              
                console.clear();
gsap.registerPlugin(ScrollTrigger);
const tl = gsap.timeline({
  defaults: { duration: 1 }, 
  paused: true,
  scrollTrigger: { 
    trigger:".section",
    start: "center bottom",
    end: "center top",
    markers: true,
          
    scrub :true
    // ... 
  }
});
const startScrollTL = gsap.timeline({
  scrollTrigger: { 
    trigger:".section",
    markers: true,
          
     // ... 
  }
});
const TLDur2 = tl.duration();
console.log(TLDur2)
var total = tl.totalDuration(); 
console.log(total)
const canvas = document.getElementById("goldenhemp-canvas");
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 tween = gsap.to(airpods, {
  frame: frameCount - 1,
  snap: "frame",
  onUpdate: render // use animation onUpdate instead of scrollTrigger's onUpdate
});
tl.add(tween)
images[0].onload = render;

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

// Get the duration of the timeline to use for our positioning
const TLDur = tl.duration();
console.log(TLDur)
var myElems = document.querySelectorAll(".section div");
// Create the animations for each section 
myElems.forEach((elem, i) => {
  // Set things up
  const myStartTime = elem.dataset.startpercent/100 * TLDur;
  const myDur = (elem.dataset.endpercent - elem.dataset.startpercent)/100 * TLDur;
  console.log(myStartTime)
  console.log(myDur)

  // Get other parameters here

  gsap.set(elem, {
    position: 'fixed',
    // Other styles set here
  });

  // Animate the position and autoAlpha separately for more fine control
  startScrollTL.fromTo(elem, {
    autoAlpha: 1
  }, {
    autoAlpha: 0,
    duration: myDur,
    // I used a modified slow ease with yoyoMode: true to go in and out in one tween for this ease
    // https://greensock.com/docs/v3/Eases/SlowMo
    ease: "none"
  }, myStartTime)
  .to(elem, {
    // I only animated y here but you can do whatever
    y: () => `-${elem.dataset.endy - elem.dataset.starty}vh`,
    duration: myDur,
    ease: "none"
  }, myStartTime)
});
              
            
!
999px

Console