Jump to content
Search Community

How to hide split text element on page load

cerealbeast test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

I haven't used GSAP for quite a while and I am struggling to remember how to correctly hide text on page load using autoAlpha. Would be super appreciative if someone could show me where to add to below code. Thanks!

 

jQuery(document).ready(function ($) {
  (function () {
    let chck_if_gsap_loaded = setInterval(function () {
      const eleBuilder = document
        .querySelector("body")
        .classList.contains("elementor-editor-active");
      if (window.gsap && window.ScrollTrigger && !eleBuilder) {
        gsap.registerPlugin(ScrollTrigger);
        gsap.registerPlugin(SplitText);
        text_reveal();
        clearInterval(chck_if_gsap_loaded);
      }
    }, 500);

    function text_reveal() {
      const splitLines = new SplitText(".split-me p", {
        type: "lines",
        linesClass: "scroll-reveal scroll-reveal++"
      });

      jQuery(".split-me .scroll-reveal").wrap(
        '<div class="scroll-reveal-wrapper">'
      );

      gsap.utils.toArray(".scroll-reveal").forEach((el) => {
        gsap.from(el, {
          yPercent: 200,
          duration: 1,
          ease: "power4",
          scrollTrigger: {
            trigger: el,
            start: "top 90%"
          }
          
        });
      });

      jQuery(window).resize(function () {
        splitLines.revert();
      });
    }
  })();
});

 

See the Pen VwgybXO by gwjr (@gwjr) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...