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

              
                <main id="main" class="site_wrapper" style="--copycolor: #000; inset: 0px; width: 100%; height: 100%; position: fixed; overflow: hidden;">
  <header class="header">
    <div class="header_container">
      <div class="header_logo">
        <svg width="45.292" height="40" viewBox="0 0 45.292 40">
          <path class="logo_elem fill_black" d="M40.078,5.293a17.241,17.241,0,0,1,5.215,12.519,16.516,16.516,0,0,1-5.254,12.316,18.2,18.2,0,0,1-12.9,5.19H11.884A17.553,17.553,0,0,0,0,40V5.884A5.884,5.884,0,0,1,5.883,0H27.3a17.251,17.251,0,0,1,12.78,5.293"></path>
        </svg>
      </div>
    </div>
  </header>
  <div class="scroll_container">
    <div id="content">
      <section class="section hero" style="background-color:#ff8888">

      </section>
      <section data-color="#FF1F54" class="section scroll_text">

      </section>

      <section class="case_studies_carousel">

        <div data-color="#C11433" data-secondcolor="#E0FC35" data-text="white" class="study_wrapper">
          <div class="study_inner">
            <div class="study_image">
                <img class="image_cover" src="https://images.unsplash.com/photo-1638913662584-731da41f5a59?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=80&raw_url=true&ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070" alt="">
            </div>
          </div>
        </div>

        <div data-color="#13181B" data-secondcolor="#FF1F54" data-text="white" class="study_wrapper">
          <div class="study_inner">
            <div class="study_image">
              
                <img class="image_cover" src="https://images.unsplash.com/photo-1652804869634-06877de0347d?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=80&raw_url=true&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2832" alt="">
              
            </div>
          </div>
        </div>

        <div data-color="#DBB39B" data-secondcolor="#B85118" data-text="black" class="study_wrapper">
          <div class="study_inner">
            <div class="study_image">
                <img class="image_cover" src="https://images.unsplash.com/photo-1652489997188-abf61949a809?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=80&raw_url=true&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070" alt="">
             
            </div>
          </div>
        </div>
        <div class="end_carousel"></div>
      </section>
    </div>
  </div>
</main>
              
            
!

CSS

              
                :root {
  --sectioncolour: #fff;
  --maincolor: #fff;
  --secondcolor: #FF1F54;
  --copycolor: #13181B;
  --select-border: #000;
  --select-focus: #FF1F54;
  --select-arrow: var(--select-border);
}

html {
  box-sizing: border-box;
}

audio,
canvas,
iframe,
img,
svg,
video {
  vertical-align: middle;
}

* {
  box-sizing: border-box;

  &:before {
    box-sizing: border-box;
  }

  &:after {
    box-sizing: border-box;
  }

  &:focus {
    outline: none;
  }
}

html,
body {
  -webkit-font-smoothing: antialiased;
  // background-color: var(--maincolor);
  color: var(--copycolor);
  font-family: 'Montserrat', sans-serif;
  font-size: 100%;
  font-weight: 300;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  transition: background-color 2s;
}

body {
  transition: background-color 2s;

  &.single-casestudies {
    .section {
      min-height: auto !important;

      &.pre_footer {
        min-height: 100vh !important;
        background-color: #fff;
      }
    }
  }
}

audio,
canvas,
iframe,
img,
svg,
video {
  vertical-align: middle;
}

figure {
  margin: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

textarea {
  resize: vertical;
}



p {
  color: var(--copycolor);
  margin: 0 0 1rem;

  &.section_title {
    color: var(--secondcolor);
    margin: 0;
  }
}

ul {
  margin: 0 0 1rem;
  li {
    margin: 0 0 1rem;
  }
}

ol {
  margin: 0 0 1rem;
  li {
    margin: 0 0 1rem;
  }
}

a {
  font-size: inherit;
  display: inline-block;
  position: relative;
  color: var(--copycolor);
  text-decoration: none;

  &:after {
    content: '';
    position: absolute;
    bottom: -0.1875rem;
    left: 0;
    width: 0;
    height: 1px;
    transition: width .25s;
  }

  &:hover {
    &:after {
      width: 100%;
    }
  }

  &.arrow_link {
    display: flex;
    align-items: center;

    .link_arrow {
      width: 2rem;
      margin-left: 1rem;
      transition: margin-left .25s;
    }

    &:after {
      content: none;
    }

    &:hover {
      .link_arrow {
        margin-left: 1.5rem;
      }
    }
  }
}

hr {
  width: 2.625rem;
  margin: 1rem 0 2rem;
  height: 1px;
  border: 0;
  padding: 0;

  &.pre_footer_rule {
    margin: 5rem 0;
  }
}


img {
  height: auto;
  width: 100%;
}

svg {
  overflow: visible;
}

strong {
  font-weight: 600;
}


.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  overflow: hidden;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

.video_wrapper {
  height: 0;
  padding-bottom: 56.25%; /* 16:9 */
  padding-top: 25px;
  position: relative;

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

  video {
    height: auto !important;
    width: 100% !important;
  }
}

.header {
  width: 90%;
  padding: 1rem 0;
  background-color: transparent;
  position: fixed;
  top: 2rem;
  left: 5%;
  margin: 0 auto;
  z-index: 10;

  .header_container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;

    .header_logo {
      width: 3rem;

      svg {
        path {
          fill: var(--copycolor);
        }
      }
    }
  }
}

.site_wrapper {
  position: relative;
  overflow-x: hidden;
  background-color: var(--maincolor);
  transition: background-color 1s;
}

.section {
  position: relative;
  min-height: 100vh;
}

.block_title {
  padding: 0;
  margin-top: -2rem;
}

.case_studies_carousel {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 100vh;
  position: relative;
}

.study_wrapper {
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;

  .study_inner {
    width: 80%;
    margin: 0 auto;
    position: relative;

    a {
      display: block;
    }
  }

  .study_title {
    position: absolute;
    bottom: 5rem;
    left: 0;
  }

  .study_image {
    width: 70%;
    margin-left: 30%;
  }
}

.block_content {
  margin-left: 10%;
  padding-right: 5rem;
}
              
            
!

JS

              
                  let smoother = ScrollSmoother.create({
    wrapper: '.site_wrapper',
    content: '.scroll_container',
    effects: true,
    smooth: 1.25,
    smoothTouch: 0
  });

  smoother.effects('.speed_5', {
    speed: 1.15,
  })
  
  smoother.effects('.speed_4', {
    speed: 1.05,
  })

  smoother.effects('.speed_3', {
    speed: 1,
  })
  
  smoother.effects('.speed_2', {
    speed: 0.95,
  })
  
  smoother.effects('.speed_1', {
    speed: 0.85,
  })

const site_wrapper = document.querySelector(".site_wrapper");
const carousel = document.querySelector('.case_studies_carousel');
const studysections = gsap.utils.toArray(".study_wrapper");
let maxWidth = 0;

const getMaxWidth = () => {
  maxWidth = 0;
  studysections.forEach((section) => {
    maxWidth += section.offsetWidth;
  });
};

const colorGrab = (array) => {
  let colors = {
    firstcolor: null,
    lastcolor: null,
    firstsecondarycolor: null,
    lastsecondarycolor: null,
    textcolour: null
  };

  array.forEach((item, i) => {
    if (i === 0) {
      colors.firstcolor = item.dataset.color;
      colors.firstsecondarycolor = item.dataset.secondcolor;
      colors.firsttextcolor = item.dataset.text;
    }
    if (i === array.length - 1) {
      colors.lastcolor = item.dataset.color;
      colors.lasttextcolor = item.dataset.text;
      colors.lastsecondarycolor = item.dataset.secondcolor;
    }
  });

  return colors;
};

const carouselColors = colorGrab(studysections);
getMaxWidth();
ScrollTrigger.addEventListener("refreshInit", getMaxWidth);

// FIXES HORIZONTAL SCROLLING ELEMENT
let hCarousel = gsap.to(studysections, {
  x: () => `-${maxWidth - window.innerWidth}`,
  ease: "none",
  scrollTrigger: {
    trigger: ".case_studies_carousel",
    pin: true,
    scrub: true,
    end: () => `+=${maxWidth}`,
    invalidateOnRefresh: true
  }
});

console.log("main starts at", carousel.getBoundingClientRect().left);

ScrollTrigger.create({
  trigger: ".case_studies_carousel",
  start: "top center",
  scrub: true,
  end: () => `+=${maxWidth + window.innerHeight}`,
  invalidateOnRefresh: true,
  onEnter: () => {
    site_wrapper.style.backgroundColor = carouselColors.firstcolor;
    site_wrapper.style.setProperty(
      "--copycolor",
      carouselColors.firsttextcolor
    );
    document.body.style.setProperty(
      "--secondcolor",
      carouselColors.firstsecondarycolor
    );
  },
  onLeave: () => {
    site_wrapper.style.backgroundColor = carouselColors.lastcolor;
    site_wrapper.style.setProperty("--copycolor", "#000");
    document.body.style.setProperty("--secondcolor", "#FF1F54");
  },
  onLeaveBack: () => {
    site_wrapper.style.backgroundColor = carouselColors.firstcolor;
    site_wrapper.style.setProperty("--copycolor", "#000");
    document.body.style.setProperty("--secondcolor", "#FF1F54");
  },
  onEnterBack: () => {
    site_wrapper.style.backgroundColor = carouselColors.lastcolor;
    site_wrapper.style.setProperty("--copycolor", carouselColors.lasttextcolor);
    document.body.style.setProperty(
      "--secondcolor",
      carouselColors.lastsecondarycolor
    );
  }
});

// ISSUE WITHIN THIS FOREACH

studysections.forEach((sct, i) => {
  const color = sct.getAttribute("data-color");
  const seccolor = sct.getAttribute("data-secondcolor");
  const textcolor = sct.getAttribute("data-text");
  console.log(i, "starts at", sct.getBoundingClientRect().left);

  ScrollTrigger.create({
    containerAnimation: hCarousel,
    trigger: sct,
    start: "left center",
    end: "right center",
    scrub: true,
    markers: true,
    onEnter: () => {
      site_wrapper.style.backgroundColor = color;
      site_wrapper.style.setProperty("--copycolor", textcolor);
      document.body.style.setProperty("--secondcolor", seccolor);
    },
    onEnterBack: () => {
      site_wrapper.style.backgroundColor = color;
      site_wrapper.style.setProperty("--copycolor", textcolor);
      document.body.style.setProperty("--secondcolor", seccolor);
    }
  });
});

///////////////////

gsap.utils.toArray(".section").forEach(function (elem) {
  const color = elem.getAttribute("data-color");
  ScrollTrigger.create({
    trigger: elem,
    start: "top 50%",
    end: "bottom 50%",
    onEnter: () => (site_wrapper.style.backgroundColor = color),
    onLeave: () => (site_wrapper.style.backgroundColor = "#fff"),
    onLeaveBack: () => (site_wrapper.style.backgroundColor = "#fff"),
    onEnterBack: () => (site_wrapper.style.backgroundColor = color)
  });
});

              
            
!
999px

Console