Jump to content


Using TextPlugin with Repeat

Moderator Tag
Go to solution Solved by OSUblake,

Recommended Posts

Hi all


I'm trying to animate the "writing" of random text on repeat.


Here's what I came up with so far:


gsap.to('#text', {duration:10, repeat:-1, repeatRefresh:true, text:{value:rndstr(27)}})


rndstr(x) is a custom function that returns a random string of lenght x.


This works fine the first time it's running (it fills the div with a random 27-char string as expected, however it doesn't seem to repeat (or at least it won't fetch a new string on repeat).


Is my use of "repeatRefresh" not sufficient to have gsap fetch a new string? What am I missing?



See the Pen BaWpWPq by remo-pini (@remo-pini) on CodePen

Link to comment
Share on other sites

  • Solution
1 minute ago, remopini said:

What am I missing?


A function to call on every refresh.

gsap.to('#textbox1', {
  duration: 1, // duration should be a number, not a string
  text:{value: () => rndstr(20)}


  • Like 3
Link to comment
Share on other sites

Great! Thx. Codepen updated to reflect solution.

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.