Jump to content
Search Community

splitText line "Cannot Read property nodeType of null"

Burning Stick Creative test
Moderator Tag

Recommended Posts

Im trying to split a paragraph into lines. Im splitting it twice, so the child div line can slide up  like this

 

I get the error "TypeError: Cannot read property 'nodeType' of null"

I tried with the type being "words" and that works fine, and also with "lines" just one time. That works too. It only seems to break when I try to split it twice.

Any ideas on what Im doing wrong? Its in a vue project if that matters.

 

Off topic too, but how would one have each class of ".split" have an independent scroll trigger? 

   const pChild = new SplitText(".split", {
        type:"lines",
        linesClass:"wordChild"
      });

  
      const pParent = new SplitText(".split", {
        type:"lines",
        linesClass:"wordParent"
      });
.wordChild {
  overflow: hidden;
}
.wordParent {
  display: inline-block;
}

 

Link to comment
Share on other sites

Hey there. As the demo in the other thread shows, it seems to work fine for me.

 

Can you please create a minimal demo that exemplifies the issue using CodePen? You should be able to just fork the demo in the other thread and then edit it until you can recreate the error.

 

Link to comment
Share on other sites

@ZachSaucier

Cant seem to replicate it in codepen. Oddly enough 

       let pChild = new SplitText("p", {
        type:"lines",
        linesClass:"wordChild"
      });
      
let pParent = new SplitText("p", {
        type:"words lines",
        linesClass:"wordParent"
      });

Adding words to the second split prevents the error from happening. Not sure why? I guess it works as a temporary fix

Link to comment
Share on other sites

4 minutes ago, Burning Stick Creative said:

how would one have an independent scroll trigger for each paragraph? To where each paragraph is independent of each other for triggering the animation in?

Loop through each paragraph, creating a split, animation, and ScrollTrigger for each paragraph (making sure to scope the variables to that particular paragraph). I showed how to do that sort of thing in this post:

For more info check my article on animating efficiently.

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...