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

              
                <body class="body">
  <div class="greenline"></div>

  <div class="main-wrapper">

    <section class="section" style="background-color: red"></section>

    <section id="gather" class="section section--showcase">

      <div class="showcase">
        
        <div class="project a-project a-project-1" data-title="Data Title 1" data-meta="Data Meta 01">
          <div class="gallery a-gallery a-gallery-0">

            <div class="image a-image a-image-1" data-caption="Data Caption 1">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A2033-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-2" data-caption="Data Caption 2">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A7527-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-3" data-caption="Data Caption 3">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A7538-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-4" data-caption="Data Caption 4">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A8100-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-5" data-caption="Data Caption 5">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A8236-1024x683.jpg" style="height:100%" />
            </div>

          </div>

        </div>

        <div class="project a-project a-project-2" data-title="Data Title 2" data-meta="Data Meta 02">

          <div class="gallery a-gallery a-gallery-0">

            <div class="image a-image a-image-1" data-caption="Data Caption 6">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A8975-1-1024x1024.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-2" data-caption="Data Caption 7">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A8847-1024x1024.jpg" style="height:80%" />
            </div>

            <div class="image a-image a-image-3" data-caption="Data Caption 8">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A8863-2-1-1024x683.jpg" style="height:70%" />
            </div>

            <div class="image a-image a-image-4" data-caption="Data Caption 9">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/086A8890-1024x1024.jpg" style="height:90%" />
            </div>

          </div>

        </div>

        <div class="project a-project a-project-3" data-title="Data Title 3" data-meta="Data Meta 3">

          <div class="gallery a-gallery a-gallery-0">

            <div class="image a-image a-image-1" data-caption="Data Caption 10">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/Drew-Nocente-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-2" data-caption="Data Caption 11">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/Drew-Food-Workshop-1024x683.jpg" style="height:100%" />
            </div>

          </div>

        </div>

        <div class="project a-project a-project-4" data-title="Data Title 4" data-meta="Data Meta 4">

          <div class="gallery a-gallery a-gallery-0">

            <div class="image a-image a-image-1" data-caption="Data Caption 12">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/Maha-Co-1-1-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-2" data-caption="Data Caption 13">
              <img src="https://reroutefest.com/wp-content/uploads/2022/09/Maha-Co-2-1-1024x683.jpg" style="height:100%" />
            </div>

            <div class="image a-image a-image-3" data-caption="Data Caption 14">
              <img src="" style="height:100%" />
            </div>

          </div>

        </div>

        <div class="info-wrapper a-info-wrapper fixed-section">
          <div class="project-info a-project-info">
            <div class="work-title a-work-title rift"></div>
            <div class="meta-info a-meta-info"></div>
          </div>
          <div class="img-caption a-img-caption"></div>
        </div>

      </div>

    </section>

    <section class="section" style="background-color: purple;">
    </section>

  </div>
              
            
!

CSS

              
                section,
.showcase {
  height: 100vh;
}
.showcase,
.gallery,
.image {
  display: flex;
  flex-wrap: nowrap;
  position: relative;
  align-items: center;
}
.image {
  height: 30vh;
}
.info-wrapper {
  position: absolute;
  left: 0;
  bottom: 5%;
  color: black;
}
.greenline {
  border: 1px solid green;
  height: 100vh;
  width: 1px;
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 50%;
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

// Dynamic image class names for sections
const aImages = gsap.utils.toArray(".a-image");
aImages.map((v, i) => {
  v.className = `image a-image a-image-${i + 1}`;
});

// Getting the elements for manipulation
const a_textSection = document.querySelector(".a-fixed-section");
const a_workTitle = document.querySelector(".a-work-title");
const a_metaInfo = document.querySelector(".a-meta-info");
const a_imgCaption = document.querySelector(".a-img-caption");
const a_projectSection = document.querySelector(".a-project");
const a_image = document.querySelector(".a-image");
const a_imageOne = document.querySelector(".a-image-1");
const a_galleryScroll = document.querySelector(".a-gallery");

// Setting arrays for dynamic animations
const a_gallery = gsap.utils.toArray(".a-gallery");
const a_sections = gsap.utils.toArray(".a-project");
const a_imgCaptionsArr = gsap.utils.toArray(".a-image");

// Setting the scrollTrigger for the filling blank areas before user see it
const a_project = document.querySelector(".a-project-1");
ScrollTrigger.create({
  trigger: ".bluebars",
  onEnter: () => {
    a_workTitle.innerText = a_project.dataset.title;
    a_metaInfo.innerHTML = a_project.dataset.meta;
    a_imgCaption.innerText = a_imageOne.dataset.caption;
  }
});

// Mapping all data-captions for the img captions
a_imgCaptionsArr.map((a_capt, a_index) => {
  ScrollTrigger.create({
    trigger: `.a-image-${a_index + 1}`,
    start: `top+=${a_index * 0.95 * a_image.offsetWidth * 1.033} top`,
    onEnter: () => {
      a_imgCaption.innerText = a_capt.dataset.caption;
    },
    onEnterBack: () => {
      a_imgCaption.innerText = a_capt.dataset.caption;
    }
  });
});

// Calculations for the slider trigger
a_sections.map((a_section, a_index) => {
  console.log(a_section);
});

// Mapping all data-title
a_sections.map((a_section, a_index) => {
  ScrollTrigger.create({
    trigger: a_section,
    start: `top+=${(a_index * a_gallery[a_index].clientWidth) / 2.05}% center`,
    markers: true,
    onEnter: () => {
      a_workTitle.innerText = a_section.dataset.title;
    },
    onLeaveBack: () => {
      a_workTitle.innerText = a_section.dataset.title;
    }
  });
});

// Mapping all data-meta
a_sections.map((a_section, a_index) => {
  ScrollTrigger.create({
    trigger: a_section,
    start: `top+=${(a_index * a_gallery[a_index].clientWidth) / 2.05}% center`,
    onEnter: () => {
      a_metaInfo.innerHTML = a_section.dataset.meta;
    },
    onLeaveBack: () => {
      a_metaInfo.innerHTML = a_section.dataset.meta;
    }
  });
});

let a_maxWidth = 0;

const a_getMaxWidth = () => {
  a_maxWidth = 0;
  a_sections.forEach((a_section) => {
    a_maxWidth += a_section.offsetWidth;
  });
};
a_getMaxWidth();
ScrollTrigger.addEventListener("refreshInit", a_getMaxWidth);

gsap.to(a_sections, {
  x: () => `-${a_maxWidth - window.innerWidth / 1.5}`,
  ease: "none",
  scrollTrigger: {
    trigger: ".section--showcase",
    pin: true,
    scrub: true,
    end: () => `+=${a_maxWidth}`,
    invalidateOnRefresh: true
  }
});

a_sections.forEach((a_sct, i) => {
  ScrollTrigger.create({
    trigger: a_sct,
    start: () =>
      "top top-=" +
      (a_sct.offsetLeft - window.innerWidth / 2) *
        (a_maxWidth / (a_maxWidth - window.innerWidth)),
    end: () =>
      "+=" + a_sct.offsetWidth * (a_maxWidth / (a_maxWidth - window.innerWidth))
  });
});

              
            
!
999px

Console