Jump to content
Search Community

SplitText not breaking hyphenated words

R.J. LaCount test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

I'm encountering what I believe is a very similar issue to this thread, but I can't seem to get the applicable part of the solution to work in my context.

 

I have some large hero copy in a narrow container with a hyphenated word that SplitText is unable to break apart. From what I'm reading in the linked thread, this is happening because the one "word" cannot be split into multiple divs, so I need to swap in a non-breaking dash character in for the regular one, but I'm not having luck pulling that part out into my demo.

 

Attached a couple of screenshots in case the hyphenated word is not rendering at the same spot on your end in the Codepen example.

02-after-splittext.png

01-before-splittext.png

See the Pen dEEPwo by TheFunkyMonk (@TheFunkyMonk) on CodePen

Link to comment
Share on other sites

3 minutes ago, Visual-Q said:

If I'm understanding your request adding "words' to your split text type seems to make hyphens break correctly.

 


const split = new SplitText(text, { type: 'lines','words' });

 

 

I think you're seeing it break correctly after that change because the object isn't formatted correctly (should be

{  type: 'lines, words' }

) which is causing a JavaScript error preventing SplitText from running at all.

Link to comment
Share on other sites

  • 2 years later...

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