Jump to content
Search Community

applying cLassName property to hypen separated class

bromel test
Moderator Tag

Go to solution Solved by Shaun Gorneau,

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

Hello all

 

Just something I noticed

 

In gsap I can change tween or change a class by simply doing

TweenMax.to(myClass,.3,{className:"yourClass"});

so we can tween myClass to yourClass, but I get a console error if the classname has a '-' in it for example

TweenMax.to(myClass-hypen,.3,{className:"yourClass"});

The following console msg proceeds:

Uncaught TypeError: t.split is not a functionse @ TweenMax.min.js:15l.parse @ TweenMax.min.js:15l.parse @ TweenMax.min.js:16ye.parser @ TweenMax.min.js:16l._onInitTween @ TweenMax.min.js:16n._initProps @ TweenMax.min.js:16n._init @ TweenMax.min.js:16n.render @ TweenMax.min.js:17l.render @ TweenMax.min.js:14n.render @ TweenMax.min.js:16O._updateRoot.D.render @ TweenMax.min.js:16n.dispatchEvent @ TweenMax.min.js:16g @ TweenMax.min.js:16

So I am assuming that the Classname property does not like changing hyphenated classes although the '+=' and '-=' atributes work as expected.

 

Any thoughts?

 

bromel

Link to comment
Share on other sites

  • Solution

Where you are using myClass ... that's an object, not a string. Just like in naming any variable, hyphens are not allowed. If I did the following

a = 0;
b = 1;
a-b = 2; // <- I'm saying a minus b = 2

If you want to tween a class name (with or without a hyphen), reference the object with the class selector

TweenMax.to(".myClass-hypen", .3, {className:"yourClass"});

See the Pen GpRaRe by sgorneau (@sgorneau) on CodePen

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