Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <section id="timeline-02" class="timeline hscroll">
        <div class="module has-panel has-overlay full-width bg-ocean">
            <div id="timeline-02-inner" class="panel has-layers">
                <div class="container">
                    <svg class="circle-bg  align-right" xmlns="http://www.w3.org/2000/svg" width="1320" height="1250" viewBox="0 0 1265 1250">
                        <circle class="svg-circle blue-trans" cx="625" cy="625" r="625" fill="#0d76a5"/>
                    </svg>
                    <div class="scroll-indicator">Scroll down &darr;</div>
                    <div class="block align-right from-right textbox text-1">
                        <h2><span>This is a lead-in heading &hellip;</span></h2>
                    </div>
                    <div class="block align-right from-right textbox text-2">
                        <p>First block of text - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
                      <p class="continue">Scroll to continue...</p>
                    </div>
                    <div class="block align-right from-right textbox text-3">
                        <p>Second block of text - Placerat vestibulum lectus mauris ultrices eros in. Elit at imperdiet dui accumsan. Porta nibh venenatis cras sed felis. Molestie at elementum eu facilisis sed odio morbi quis. Sit amet consectetur adipiscing elit. Diam sollicitudin tempor id eu nisl nunc mi. Porttitor eget dolor morbi non. Purus sit amet volutpat consequat mauris nunc congue nisi.</p>
                    </div>
                </div><!-- /.container -->
            </div><!-- .panel has-layers -->
            <div class="overlay"></div>
        </div>
        <div class="module blockquote blue">
            <figure class="quote">
                <blockquote>
                    <p>This is a blockquote! Faucibus in ornare quam viverra. At imperdiet dui accumsan sit amet.</p>
                </blockquote>
            </figure>
        </div>
    </section>
              
            
!

CSS

              
                /**
 * Common - Primary site-wide styles
 */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,200;0,300;0,400;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,600;1,700;1,800;1,900&family=Roboto:ital,wght@0,100;0,400;0,700;1,400;1,700&display=swap');

//* Structure
html {
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}
body {
    color: #ffffff;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 16px; // base font size
    position: relative;
}
.site-inner {
    max-width: 1040px;
    padding: 20px;
    .content {
        width: 100%;
        padding: 0;
    }
}
.container {
    max-width: 1040px;
    padding: 0 20px;
    margin: 0 auto;
    width: 100%;
    &.svg {
        position: relative;
        min-height: 100vh;
    }
}

//* Typography
h1 {
    font-size: 2.5rem;
    font-style: normal;
    line-height: 3rem;
    margin: 0 0 20px 0;
}
h2 {
    font-size: 2rem;
    line-height: 2.5rem;
    margin: 0 0 20px 0;
}
p {
    font-size: 1.2rem;
    line-height: 1.625;
}

.bg-overlay {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.6) 49.94%, rgba(0, 0, 0, 0) 82.81%);
    z-index: -1;
}

/**
 * Shapes
 */

.circle {
    border-radius: 100%;
}

svg {
    .blue-trans {
      fill: rgba(#0d76a5, 0.75);
    }
    &.circle-bg {
        max-width: 1285px;
        height: auto;
    }
    &.align-right {
        position: absolute;
        top: -10%;
        right: -48%;
    }
    &.align-left {
        position: absolute;
        top: -10%;
        left: -55%;
    }
}


/**
 * Timeline - Styles theme/timeline-based pages
 */
.scroll-indicator {
  color: #0d76a5;
  font-size: 2rem;
  font-weight: bold;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 1rem;
}
.continue {
  font-weight: 700;
}

// primary timeline structure for scrolling panels & modules
.timeline {
    position: relative;
    height: 100vh;
    min-height: 800px;
    overflow-y: clip;
    &.hscroll {
        display:flex;
        flex-wrap:wrap;
        flex-direction:column;
    }
    &.bg-black {
        background-color: #000;
    }
}
.panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    &.text-panel {
        display: flex;
        align-items: center;
    }
}
.module {
    display: flex;
    align-items: center;
    height: 100%;
    &.full-width {
        width: 100%;
    }
    &.full-width-partial {
        width: 90%;
    }
    &.test {
        width: 500px;
    }
    &.blockquote {
        padding: 5%;
        width: 30%;
        z-index: 0;
        &.lg {
            width: 40%;
        }
        &.ext-lg {
            width: 60%;
            padding: 5% 8%;
            .quote {
                max-width: 100%;
            }
        }
        p {
            font-size: 1.25rem;
            line-height: 1.875;
        }
        .quote {
            max-width: 425px;
        }
        &.eggplant {
            p {
                color: #61429A;
            }
        }
        &.blue {
            p {
                color: #0d76a5;
            }
        }
        &.force-left {
            .quote {
                position: absolute;
                left: -500px;
            }
        }
    }
    &.textblock {
        padding: 5%;
        width: 30%;
    }
}

// content elements
.block {
    max-width: 500px;
    padding: 20px 0;
    &.align-right {
        margin-left: auto;
    }
    &.align-left {
        padding-left: 20px;
    }
    &.full-width {
        max-width: inherit;
        width: 100%;
    }
    &.bring-to-top {
        z-index: 2;
    }
  p {
    & + p {
      margin-top: 1rem;
    }
  }
}
.bring-to-top {
    z-index: 5;
}
.textbox {
    z-index: 1;
}
.center-wrap {
    margin: 0 auto;
}
.theme-title {
    font-weight: 600;
}
.subhead {
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.75px;
}
.has-overlay {
    position: relative;
    z-index: 1;
    overflow: hidden;
    .overlay {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-color: rgba(0, 0, 0, .5);
        z-index: -1;
        &.darker {
            background-color: rgba(0, 0, 0, .7);
        }
    }
}

.has-panel {
    position: relative;
    .overlay { // alternate overlay settings for layers + slide-out quote panel type
        z-index: 1;
        background-color: rgba(0, 0, 0, .4);
    }
}
.has-layers {
    overflow: hidden; // clipping SVG circle so it doesn't overlap slide-out quote block
    .container {
        display: flex;
        align-items: center;
        position: relative;
        min-height: 100vh;
    }
    .textbox {
        position: absolute;
        padding-top: 90px; // offset fixed header height
        &.align-right {
            right: 0;
        }
        &.align-left {
            left: 0;
        }
    }
}

.bg-ocean {
    background: url(https://images.unsplash.com/photo-1488188840666-e2308741a62f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2074&q=80) no-repeat center center;
    background-size: cover;
}
              
            
!

JS

              
                // Register GSAP plugins
gsap.registerPlugin(ScrollTrigger);

//* Set properties of common elements
gsap.set('.svg-circle', {opacity: 0, scale: 0.25, transformOrigin: '50% 50%'});
gsap.set('.from-right', {opacity: 0, x: 150});
gsap.set('.overlay', {opacity: 0});

let hscroll2 = document.getElementById("timeline-02");
let tl = gsap.timeline({ scrollTrigger: {
    trigger: "#timeline-02",
    start: "top top",
    end: () => "+=3500",
    scrub: true,
    pin: true,
    invalidateOnRefresh: true
}})
.to({}, {duration: 1})
tl.add(() => {
  //maybe you need to go to different values if it's going backwards...
  if (tl.scrollTrigger.direction === -1) {
    gsap.to("#timeline-02 .svg-circle", {duration: 0.75, scale: 0, autoAlpha: 0});
    // gsap.to("#timeline-02 .text-1", {duration: 0.5, opacity: 0, x: 150});
  } else {
    gsap.to("#timeline-02 .svg-circle", {duration: 0.75, scale: 1, autoAlpha: 1});
    // gsap.to("#timeline-02 .text-1", {duration: 0.5, opacity: 1, x: 0});
  // non-scrubbed. Just a regular animation that's triggered at a certain spot in the timeline
  }
})

.to("#timeline-02 .text-1", {duration: 0.5, opacity: 0, x: 150})
.to("#timeline-02 .text-2", {duration: 0.45, opacity: 1, x: 0})
.to({}, {duration: 1})
.to(hscroll2, {
    x: () => -(hscroll2.scrollWidth - document.documentElement.clientWidth) + "px",
    ease: "none",
})


/*-- TIMELINE ANIMATIONS --*/
/* inner animation */
/*
let hscroll2Inner = document.getElementById("timeline-02-inner")
var panel2Inner = gsap.timeline();
panel2Inner.to("#timeline-02 .svg-circle", {duration: 0.5, scale: 1, autoAlpha: 1})
.to("#timeline-02 .scroll-indicator", {duration: 0.5, opacity: 0})
.to("#timeline-02 .text-1", {duration: 0.5, opacity: 1, x: 0})
.to({}, {duration: 1})
.to("#timeline-02 .text-1", {opacity: 0})
.to("#timeline-02 .text-2", {duration: 0.45, autoAlpha: 1, x: 0})
.to({}, {duration: 0.5})
ScrollTrigger.create({
    animation: panel2Inner,
    trigger: "#timeline-02-inner",
    start: "top top",
    scrub: false,
    // pin: true,
    toggleActions: "play pause resume reset"
});
/* inner animation end */

/* horizontal animation w/ scrubbing */
/*
let hscroll2 = document.getElementById("timeline-02")
var panel2 = gsap.timeline();
panel2.to({}, {duration: 1})
.to("#timeline-02 .text-2", {autoAlpha: 0})
.to("#timeline-02 .text-3", {duration: 0.45, opacity: 1, x: 0})
.to({}, {duration: 1})
.to("#timeline-02 .overlay", {duration: 1, autoAlpha: 1})
.to(hscroll2, {
    x: () => -(hscroll2.scrollWidth - document.documentElement.clientWidth) + "px",
    ease: "none",
})
.to({}, {duration: 1})
ScrollTrigger.create({
    animation: panel2,
    trigger: "#timeline-02",
    start: "top top",
    end: () => "+=3500",
    scrub: true,
    pin: true,
});
/* horizontal animation end */
              
            
!
999px

Console