Jump to content
Search Community

SplitText: <br> tags and spaces

pakl test
Moderator Tag

Go to solution Solved by GreenSock,

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

I'm working on applying styling to certain words after using SplitText. To do this I'm relying on the word index but I see some inconsistencies when a linebreak is considered a word and when it isn't.


The following pen illustrates:



As you can see when a linebreak is followed or preceded by a space it will end up as a separate line and word after SplitText but if two or more linebreaks are not separated by anything else, they are combined into one line/word.


I think it's fair to consider this a bug. A linebreak should always end up as its own line with its own word, or am I missing something?

See the Pen goGuA by patrickklug (@patrickklug) on CodePen

Link to comment
Share on other sites

@Jack what is the best way to link to the latest version in a codepen?


I tried the new version locally and it seems that there is a breaking bug.


Using splittext on 'This is a test<br><br>Normal italic bold underline' returns a `.words` array with only 3 elements.

Link to comment
Share on other sites

  • Solution

Please snag 0.3.2 now and give that a shot - it should fix all the <br> issues and the faulty words array that was introduced in that [wrong] file yesterday. Again, I apologize for the mix-up. Please let me know if things work well for you now. Oh, and if you want to use it on codepen, this URL should work: https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/SplitText.min.js

  • Like 3
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...