Jump to content
Search Community

[SplitText][ScrambleText] - "Decode" animation with white space

dotmot

Recommended Posts

Posted

Hello,Β 

Does anyone know how to handle spaces when scrambling split text?
When a string contains a space the same amount of spaces is missing in the end of the animation.


This animation is the same as this previous one but i did not account for spaces

Β 

See the Pen wvOrqOy by Dotmot (@Dotmot) on CodePen.

Posted

Hi,

Β 

Sorry for the delay πŸ™

Β 

What exactly is the issue here? The fact that the last letter is not being animated? If so just remove the empty space from the array:

const split_message = [
  "W",
  "e",
  "l",
  "c",
  "o",
  "m",
  "e",
  "B",
  "a",
  "c",
  "k"
];

For SplitText spaces are not characters and therefore are not accounted for in the instance's chars array, so the arrays lengths don't match, one has 12 elements (split_message) and the other has 11 (split_text.chars)

console.log(msg.innerText, msg.innerText.length); // γ‚Όγƒ…γƒŒγƒ‚γƒγƒγƒ… ウγ‚ͺγ‚·γ‚Ί 12
console.log(split_text.chars); // 11
console.log(split_message.length); // 12 - with the space in the array

Here is a fork of your demo:

See the Pen pvjBdWv by GreenSock (@GreenSock) on CodePen.

Β 

Hopefully this helps

Happy Tweening!

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