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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div id="fullpage">

    <section class="section first">
        <div class="content">
            <h1>First Section </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni exercitationem maiores quo veniam, tempora consequatur amet obcaecati sequi nam voluptatem labore earum natus, minima voluptate laborum neque voluptas adipisci repellendus?</p>
        </div>
    </section>


    <section class="section seccond">
        <div class="content">
            <h1>Seccond Section </h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque quasi, atque quam delectus ab laborum ad corporis. Consequuntur molestias tenetur saepe, eveniet quibusdam qui eos expedita dicta earum accusantium commodi.</p>
        </div>
            
    </section>

    <section class="section third">
        <div class="content">
            <h1>Third Section </h1>
                <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Incidunt nisi veniam voluptate perspiciatis sequi odio dignissimos perferendis voluptatibus modi ipsa! Quae ut tempora, neque minima maxime minus excepturi omnis reprehenderit!</p>
        </div>
    </section>
</div>

              
            
!

CSS

              
                * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

section {
  color: #fff;
  position: relative;
  height: 100vh;
  width: 100vw;
}

h1 {
  font-size: 3em;
}

p {
  font-size: 1em;
}

section:nth-child(1) {
  background-color: black;
}
section:nth-child(2) {
  background-color: blue;
}
section:nth-child(3) {
  background-color: blueviolet;
}

.content {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

              
            
!

JS

              
                class Utils {
  toArray(element) {
    return [].slice.call(element);
  }
  get(selector) {
    return document.querySelector(selector);
  }
}

(() => {
  let ready = false;
  let animationTimeout, transitionTimeout;

  const hideElements = () => {
    const seccondSection = get(".seccond");
    const thirdSection = get(".third");
    const first = get(".first").children;
    const seccond = get(".seccond").children;
    const third = get(".third").children;
    gsap.to([first, seccond, third], {
      autoAlpha: 0,
      duration: 0,
      y: 300,
    });
    gsap.to([seccondSection, thirdSection], {
      scale: 0.9,
    });
  };

  const animateIn = ({ currentIndex }) => {
    const { get } = new Utils();
    const firstSection = get(".first");
    const seccondSection = get(".seccond");
    const thirdSection = get(".third");
    const first = get(".first").children;
    const seccond = get(".seccond").children;
    const third = get(".third").children;
    if (currentIndex === 0) {
      gsap.to(first, {
        autoAlpha: 1,
        y: 0,
        duration: 0.5,
        ease: Power2,
      });
      gsap.to(firstSection, {
        scale: 1,
        ease: Power1,
        delay: 0.5,
      });
    }

    if (currentIndex === 1) {
      gsap.to(seccond, {
        autoAlpha: 1,
        y: 0,
        duration: 0.5,
        ease: Power2,
      });
      gsap.to(seccondSection, {
        scale: 1,
        ease: Power1,
        delay: 0.5,
      });
    }

    if (currentIndex === 2) {
      gsap.to(third, {
        autoAlpha: 1,
        y: 0,
        duration: 0.5,
        ease: Power2,
      });
      gsap.to(thirdSection, {
        scale: 1,
        ease: Power1,
        delay: 0.5,
      });
    }
  };

  const animateOut = ({ currentIndex, direction }) => {
    const { get } = new Utils();
    const firstSection = get(".first");
    const seccondSection = get(".seccond");
    const thirdSection = get(".third");
    const first = get(".first").children;
    const seccond = get(".seccond").children;
    const third = get(".third").children;

    if (direction === "down") {
      if (currentIndex === 0) {
        gsap.to(first, {
          autoAlpha: 0,
          y: -200,
          duration: 0.5,
        });
        gsap.to(firstSection, {
          scale: 0.9,
          ease: Power1,
          duration: 0.5,
        });
      }

      if (currentIndex === 1) {
        gsap.to(seccond, {
          autoAlpha: 0,
          y: -200,
          duration: 0.5,
        });
        gsap.to(seccondSection, {
          scale: 0.9,
          ease: Power1,
          duration: 0.5,
        });
      }

      if (currentIndex === 2) {
        gsap.to(third, {
          autoAlpha: 0,
          y: -200,
          duration: 0.5,
        });
        gsap.to(thirdSection, {
          scale: 0.9,
          ease: Power1,
          duration: 0.5,
        });
      }
    } else {
      if (currentIndex === 0) {
        gsap.to(first, {
          autoAlpha: 0,
          y: 200,
          duration: 0.5,
        });
        gsap.to(firstSection, {
          scale: 0.9,
          ease: Power1,
          duration: 0.5,
        });
      }

      if (currentIndex === 1) {
        gsap.to(seccond, {
          autoAlpha: 0,
          y: 200,
          duration: 0.5,
        });
        gsap.to(seccondSection, {
          scale: 0.9,
          ease: Power1,
          duration: 0.5,
        });
      }

      if (currentIndex === 2) {
        gsap.to(third, {
          autoAlpha: 0,
          y: 200,
          duration: 0.5,
        });
        gsap.to(thirdSection, {
          scale: 0.9,
          ease: Power1,
          duration: 0.5,
        });
      }
    }
  };

  const fullPage = new fullpage("#fullpage", {
    navigation: true,
    navigationPosition: "right",
    css3: true,
    afterLoad: function (origin, destination, direction) {
      animateIn({ currentIndex: destination.index });
    },
    onLeave: function (origin, nextIndex, direction) {
      if (ready) return;
      clearTimeout(animationTimeout);
      clearTimeout(transitionTimeout);

      animateOut({ currentIndex: origin.index, direction });
      animationTimeout = setTimeout(() => {
        ready = true;
        if (direction === "down") {
          fullpage_api.moveSectionDown();
        } else {
          fullpage_api.moveSectionUp();
        }
      }, 300);

      transitionTimeout = setTimeout(() => {
        ready = false;
      }, 300);

      return ready;
    },
  });
  const { toArray, get } = new Utils();
  hideElements();
})();

              
            
!
999px

Console