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

              
                <div id="root"></div>
              
            
!

CSS

              
                .app {
  display: inline-flex;
  background-color: rgb(250, 238, 224);
  overflow: hidden;
  flex-wrap: nowrap;
}

.section1 {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffff33;
}

.section {
  position: relative;
  display: flex;
  background-color: #121212;
  color: #ffffff;
  height: 100vh;
  width: 150vh;
  justify-content: space-between;
}

.textWrapper {
  display: flex;
  align-items: center;
  flex-direction: column;
  z-index: 1;
  height: 100%;
  width: 51%;
  padding: 20vh 6.44vh 0 13.44vh;
}

.title {
  font: 600 8vh/98.49% "New York Extra Large", serif;
  letter-spacing: -0.06em;
  white-space: pre-wrap;
  margin-bottom: 6.3vh;
}

.text {
  color: #dddddd;
  font: 500 2.35vh/150% "Neue Haas Grotesk Display Pro", Arial, Helvetica,
    sans-serif;
  text-align: justify;
  white-space: pre-wrap;
}

.imageWrapper {
  position: relative;
  height: 100%;
  width: fit-content;
  display: flex;
  justify-content: flex-end;
  padding: 20vh 13.33vh 0 0;
}

.image {
  width: auto;
  clip-path: inset(0% 100% 0% 0%);
  height: 71.6vh;
}

              
            
!

JS

              
                import * as gsap from "https://cdn.skypack.dev/[email protected]";
import * as React from "https://cdn.skypack.dev/[email protected]";
import * as ReactDOM from "https://cdn.skypack.dev/[email protected]";

// Dummy component of width 100vw to mirror app version where there's such component with actual content and with this same width
const SectionOne = () => {
  return (
    <section id="section-one" data-scroll-section className="section1">
      empty test div!
    </section>
  );
};

// The component with the element I want to animate with scroll trigger
const SectionThree = () => {
  React.useEffect(() => {
    gsap.gsap.registerPlugin(ScrollTrigger);
    gsap.gsap.to("#img", {
      scrollTrigger: {
        horizontal: true,
        scroller: "#scroll",
        trigger: "#img",
        start: "left center",
        end: "left left",
        invalidateOnRefresh: true,
        markers: true,
        toggleActions: "play reverse play reverse",
        onEnter: () => {
          console.log("Enter");
        }
      },
      clipPath: "inset(0% 0% 0% 0%)"
    });
  }, []);

  return (
    <section data-scroll-section>
      <div className="section">
        <div className="textWrapper">
          <h2 className="title">A minmalistic approach to chair design</h2>
          <p className="text">
            Barn & Bed  is a chair without any unnecessary details or materials:
            it features a seat in molded polyurethane with a simple steel
            structure. This flexible, stackable chair can be used both indoors
            and outdoors, and has the potential to establish a new way of
            defining furniture for public spaces.
          </p>
        </div>
        <div className="imageWrapper">
          <img
            alt=""
            id="img"
            src="https://res.cloudinary.com/tobijudah/image/upload/v1624131934/barn-and-bed/photos/section-3_ldifxv.png"
            className="image"
          />
        </div>
      </div>
    </section>
  );
};

function App() {
  React.useEffect(() => {
    const scroll = new LocomotiveScroll({
      smooth: true,
      el: document.querySelector("#scroll"),
      direction: "horizontal",
      gestureDirection: "both",
      tablet: {
        smooth: true
      },
      smartphone: {
        smooth: true
      }
    });
    gsap.gsap.registerPlugin(ScrollTrigger);
    scroll.on("scroll", ScrollTrigger.update);
    ScrollTrigger.scrollerProxy(document.querySelector("#scroll"), {
      scrollTop(value) {
        if (scroll) {
          return arguments.length
            ? scroll.scrollTo(value, 0, 0)
            : scroll.scroll.instance.scroll.y;
        }
      },
      scrollLeft(value) {
        if (scroll) {
          return arguments.length
            ? scroll.scrollTo(value, 0, 0)
            : scroll.scroll.instance.scroll.x;
        }
      },
      getBoundingClientRect() {
        return {
          top: 0,
          left: 0,
          width: window.innerWidth,
          height: window.innerHeight
        };
      },
      pinType: document.querySelector("#scroll").style.transform
        ? "transform"
        : "fixed"
    });

    const lsUpdate = () => {
      if (scroll) {
        scroll.update();
      }
    };

    ScrollTrigger.addEventListener("refresh", lsUpdate);
    ScrollTrigger.refresh();
  }, []);

  return (
    <div id="scroll" className="app" data-scroll-container>
      <SectionOne />
      <SectionThree />
    </div>
  );
}

ReactDOM.render(<App />, document.getElementById("root"));

              
            
!
999px

Console