Jump to content
Search Community

Problem with TextPlugin with html tag

gabriele test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi!

 

I have a problem with the TextPlugin and timeline animation in which there is a html tag:

 

var tl = new TimelineMax();
tl.to("#target", 1, {text:"<ul><li>much</li><li>much</li></ul>"})
tl.add("s1");
tl.pause()
tl.to("#target", 1, {text:"<ul><li>much</li><li>much</li><li>much</li></ul>"})
tl.add("s2");
tl.pause()
 
 
$('#continue').click(function (e) {
                tl.tweenTo("s2")
            });
 
 $('#previous').click(function (e) {
               tl.tweenTo("s1")
            });
 
The control of "continue" works but for strange reason when the animation goes on "previous" the text of the target loses the html format : <ul><li> etc... are totally ignored.

Please let me know why this is happening.
Thank you.
 
Link to comment
Share on other sites

Hello gabriele, and Welcome to the GreenSock Forum!

 

Whats happening is you are trying to use the TextPlugin for DOM elements. But the TextPlugin docs state that

 

Tweens the text content of a DOM element, ...

 

So the TextPlugin is only used for the content of DOM elements and not the DOM elements itself. Like in your case of an unordered list DOM HTML markup.

 

That is why the text of the target loses the html format. ;)

 

But like Dipscom advised a codepen demo will be helpful if your still having issues.

 

Resource:

TextPlugin Docs: http://greensock.com/docs/#/HTML5/GSAP/Plugins/TextPlugin/

 

:)

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