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

              
                <!-- split-me is the class of the container which can contain one or more Elements to split. Do note that it might contain another div inside which will have a children that is to be split. For Example: .split-me > .my-div > p--->

<div class="split-me">
  <h1>Lorem Ipsum </h1>
</div>
<div class="split-me">
  <h2>is a </h2>
</div>

<div class="split-me">
  <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! Distinctio.</p>
</div>
<div class="split-me">

  <h2>is a </h2>
</div>
<div class="split-me">
  <h1>Lorem Ipsum </h1>
</div>
<div class="split-me">
  <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! Distinctio.</p>
</div>
<div class="split-me">

  <h2>is a </h2>
</div>
<div class="split-me">
  <h1>Lorem Ipsum </h1>
</div>
<div class="split-me">
  <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! Distinctio.</p>
</div>
<div class="split-me">

  <h2>is a </h2>
</div>
<div class="split-me">
  <h1>Lorem Ipsum </h1>
</div>
<div class="split-me">
  <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! DistinctioLorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptatum, possimus ullam nostrum facere ipsam in molestias iure ea numquam perspiciatis unde quasi eveniet. Nesciunt ea eligendi tempore aperiam molestiae! Distinctio.</p>
</div>
              
            
!

CSS

              
                .split-me {
  font-size: 2rem;
  font-weight: 400;
}
.split-me {
  opacity: 0;
}
.split-me .line-wrapper {
  overflow: hidden;
}

.line {
  will-change: transform;
}

              
            
!

JS

              
                gsap.registerPlugin(SplitText, ScrollTrigger);

window.addEventListener("load", init);

function init() {
  /* GETTING ERROR HERE */
  gsap.utils.toArray(".split-me").forEach(createTrigger);
}

function createTrigger(el) {
  let text = gsap.utils.toArray("h1, h2, h3, h4, h5, h6, p, li", el);

  /* GETTING ERROR HERE */
  let lines = new SplitText(text, { type: "lines", linesClass: "line" });
  let wrapLines = new SplitText(text, {
    type: "lines",
    linesClass: "line-wrapper"
  });
  let initted, finished;

  setup();

  function setup() {
    jQuery(".split-me").css("opacity", "1");
    if (finished) {
      return; // if everything has animated in, we're done.
    }
    if (initted) {
      // on window resize, we should tear things down and rebuild
      gsap.getTweensOf(lines.lines).forEach((anim) => anim.progress(0).kill());
      wrapLines.revert();
      lines.revert();
      lines.split();
      wrapLines.split();
    } else {
      ScrollTrigger.addEventListener("refreshInit", setup);
      initted = true;
    }

    gsap.set(lines.lines, { yPercent: 100 });

    lines.lines.forEach((line, i) => {
      gsap.to(line, {
        yPercent: 0,
        stagger: 1,
        duration: 2,
        rotation: 0.001,
        /* add slight rotation offset */
        ease: Expo.easeOut,
        scrollTrigger: {
          trigger: line,
          start: "top bottom"
          // markers: true,
        },
        onComplete: () => {
          finished = i === lines.lines.length - 1;
          if (finished) {
            wrapLines.revert();
            lines.revert();
            ScrollTrigger.removeEventListener("refreshInit", setup);
          }
        }
      });
    });
  }
}

/* Selectors to animate inside the DIV */
// var jQuerysplit = jQuery(
//   ".split-me h1, .split-me h2, .split-me h3, .split-me h4, .split-me h5, .split-me h6, .split-me p, .split-me li"
// );

// /* Splitting Lines */
// const splitLines = new SplitText(jQuerysplit, {
//   type: "lines",
//   linesClass: "line line++"
// });

// /* Wrapping the Lines in a DIV with class line wrapper to make animation */
// jQuery(".split-me .line").wrap('<div class="line-wrapper">');

// /* GSAP Animation */
// gsap.utils.toArray(".line").forEach((el) => {
//   gsap.from(el, {
//     yPercent: 200,
//     stagger: 1,
//     duration: 3.5,
//     stagger: 1,
//     ease: Expo.easeOut,
//     scrollTrigger: {
//       trigger: el,
//       start: "top 100%"
//       // uncomment the next line if you want the animation to reverse when scrolling backwards. Or set scrub: true to have it sync with the scrollbar position
//       // toggleActions: "play none none reverse"
//     }
//   });
// });

/* To Do:
    - Reverse the SplitLines once animation is completed. 
    - Reverse, SplitLines again and animate once window is resized.
 */

              
            
!
999px

Console