Jump to content
Search Community

Responsive behavior using SplitText

Pedro Rezende test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hello everyone! 🌟

 

I'm trying to understand how to handle SplitText responsiveness because I'm encountering some unexpected results when I resize the page.

 

In the example below, I notice that I get a different position each time I refresh the page with a different screen resolution. I'm attempting to revert the changes before reapplying SplitText.

 

Ex: After resizing to a big screen:

image.thumb.png.8627075841c0f921806f13166846b7f0.png

 

Ex2: After refreshing the page using the same screen resolution above: 

image.thumb.png.ab970913a9fcf46ae03210ba5896ebb6.png

For the effect I want to use, I really need the position property set as absolute. Also, I'm not throttling, just for simplicity. 

 

Someone could please give me a light on what I'm doing wrong / not understanding correctly?

 

Thank you very much!

 

See the Pen OJrOEXB by prznd (@prznd) on CodePen

Link to comment
Share on other sites

  • Solution

Hi Pedro,

 

It seems that the revert method is not cleaning the height and width given to the SplitText target h1. This seems to resolve the issue:

if (text) {
  text.revert();
  gsap.set("h1", { clearProps: true, }); // Remove all inline styles applied by GSAP
}

Hopefully this helps.
Happy Tweening!

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