Something's not quite right with this animation. Can you spot what's making the text... dance?
Today's Riddle
It all started with the most basic programming task: printf("Hello World")
. The Liquidcode Crew posted a challenge on Liquidcode that seemed almost insultingly simple – reinvent the classic "Hello World" greeting. Make it interesting. Make it yours.
One creative developer took that challenge and ran with it, crafting what appears to be the perfect text scrambling animation. Watch as "Hello World" morphs through random characters, gradually revealing "Bonjour le monde," then cycling through dozens of languages in an endless, hypnotic dance. A beautiful evolution from the humble printf statement.
The code is clean. The logic is sound. The animation runs smoothly.
Yet something is... off.
But there's something strange happening. The text isn't staying in one place. It's shifting slightly to the right as the letters change. It's subtle, but once you notice it, you can't unsee it.
The Code in Question
Take a look at the heart of this scrambling animation:
const morphToNextPhrase = async () => {
if (isAnimating) return;
setIsAnimating(true);
const nextPhrase = phrases[(currentPhraseIndex + 1) % phrases.length];
const maxLength = nextPhrase.length;
let morphingText = displayText.split("");
while (morphingText.length < maxLength) {
morphingText.push(" ");
}
for (let iteration = 0; iteration < 20; iteration++) {
morphingText = morphingText.map((char, index) => {
const targetChar = nextPhrase[index] || " ";
if (char === targetChar) return char;
return Math.random() < iteration / 20 ? targetChar : getRandomChar();
});
setDisplayText(morphingText.join(""));
await new Promise((resolve) => setTimeout(resolve, 50));
}
setDisplayText(nextPhrase);
setCurrentPhraseIndex((prev) => (prev + 1) % displayText.length);
setIsAnimating(false);
};
Here's how this animation works:
- Setup: It takes the current text and the next phrase to morph into
- Padding: If the new phrase is longer, it adds spaces to match the length
-
The Magic Loop: For 20 iterations, it goes through each character position:
- If the character is already correct, keep it
- Otherwise, randomly decide whether to show the correct character or a random letter
- As iterations progress, it becomes more likely to show the correct character
- Timing: Each iteration pauses for 50ms, creating the animated effect
- Finish: Finally sets the complete target phrase
The logic is elegant – characters gradually "find" their correct positions while others continue scrambling. But here's the puzzle: when transitioning from a longer phrase to a shorter one, the text suddenly shifts to the right as it gets centered. Why does this beautifully designed animation cause the text to jump around?
Your Move
This scrambling text challenge is live on Liquidcode right now, waiting for creative minds to tackle the dancing text problem. So, detective, did you identified the problem? Do you have a solution to stop the dance?
The original developer created something beautiful and functional. Now it's your turn to take their work and push it to the next level. That's the Liquidcode way – every solution becomes someone else's starting point.
Ready to Stop the Dance?
Head over to the Scrambling Animated Text challenge, and show the community how you'd solve the dancing text mystery. Whether you're a CSS wizard, a JavaScript virtuoso, or someone with a completely unexpected approach, your solution could inspire the next challenge in the chain.
The text is dancing. The challenge is waiting. Your solution could be the one that brings stability to the scramble.
Join Liquidcode today and let's start building together, where every solution sparks the next challenge
Top comments (4)
Dancing text! 💃
Interesting
You could use GSAP's scramble text module (also, it's been fully free for ~6 months now).
Interesting, thank you.