(This page includes affiliate links. If you click and purchase, I receive a small commission at no extra cost from you and that way you can support me. I only recommend tools that I have personally used and loved.)
Introduction – Scramble Text Reveal with Elementor & GSAP
In this tutorial, we will learn to different scramble effects that we can do using GSAP in Elementor.
Switch this:
document.addEventListener("DOMContentLoaded", () => {
to:
window.addEventListener("load", (event) => {
If the text is not revealing when reaching viewport.
The first code runs the code only when HTML is loaded, the second only runs the code when whole website is loaded(images, videos etc).
Reveals Automatically
From Empty or Original Text Option
Default: Reveal 90% at viewport location
1 – Reveal automatically from Empty Text or Original Text
- dm-scramble-text is the CSS class of the Heading widget. (For Elementor v4, this code will require some change. I’ll provide the changes when v4 becomes stable)
- You can change chars to any letters you want. This letters are shown when doing scramble. Some predefined options are – upperCase, lowerCase, upperAndLowerCase. (Example: in chars:”lowerCase” would show all letters from A to Z in lowercase when scrambling)
- revealDelay defines how much time it should scramble before starting the reveal process.
- speed defines how quickly should the scramble text switch.
- start: ‘top 90%” – 90% here defines at which location in viewport should the animation start. Example: if you set 50%, then the reveal will only start when the text reaches center of your viewport.
- delimiter allows you to reveal char by char OR word by word. For word by word, simply add space – ” “.
- duration is how much time should it take to reveal. Make sure your revealDelay is lower that duration.
- There are 2 text, one in from(Line 30) and one in to(Line 42). The from text defines from which text it should start with, and to text defines which text to show after scramble. In below code, the from text is empty which means no text would be shown before scrambling, the to text is set to a variable which stores our original text. (This is simply to make it easier to Elementor to work with and it is also just because of GSAP scramble works).
- If you type text: “{original}” at line 30, then it will show the original text already, then scramble and show the original text again.
Hover me for Interaction
2 – Hover to Scramble Text
- dm-scramble-text-interact is the CSS class used for Heading Widget. (For Elementor v4, the code will be updated when v4 comes out of beta)
- For any customization or changes, please read the explanation in Version 1 above;
I can also switch to another Text
3 – Hover to Scramble and Switch Text
- dm-scramble-text-interact-switch is the CSS class used for Heading Widget. (For Elementor v4, the code will be updated when v4 comes out of beta)
- For any customization or changes, please read the explanation in Version 1 above;
Hover To Keep Scrambling
4 – Looping Scramble On Mouse Hover (A bit glitchy, but use only if your ok with the animation)
- dm-scramble-text-interact-loop is the CSS class used for Heading Widget. (For Elementor v4, the code will be updated when v4 comes out of beta)
- For any customization or changes, please read the explanation in Version 1 above.
This is a bit glitchy. If you keep your mouse over the text, it starts to get small after a while. Also, it flashes the full text for 1 frames before scrambling again. This is due to the nature of how GSAP scramble is made. I’ll try to fix this in future if I find better way.
Scramble Text That Changes 🙂
5 – Scramble and Switch Text Sequence
- dm-scramble-text-sequence is the CSS class used for Heading Widget. (For Elementor v4, the code will be updated when v4 comes out of beta)
- For any customization or changes, please read the explanation in Version 1 above.
- You can change text for each different line and also add or remove extra lines. (Line 60 – 73 copy and paste this to add more lines)
- delay allows you to show text for a while before switching to new one.
IMPORTANT: Your original text that you added in Heading Widget should match the text you add in the last text in below code.