Jump to content
GreenSock

venizia03

[SOLVED] className remove existing class

Recommended Posts

Hello!

 

When one of my animation runs (the sidebar menu is opening), I want to add a class name to the body tag. I use:

 

menuTl = gsap.timeline({paused: true});
menuTl.set('body', {
			className: '+=menu-open'
		});

But this does remove any existing classes. Is there something I miss?

 

Thx!

Edited by venizia03
Indicate this has been solved
Link to comment
Share on other sites

Hey venizia03. className tweens were removed from GSAP 3. For situations like this we recommend using the .classList API:

document.body.classList.add('menu-open');

 

  • Like 1
Link to comment
Share on other sites

Thx! I will change my code right away! 😁😁

Link to comment
Share on other sites

  • 1 year later...

I am facing the same issue, when I add the class to the element the class is add, but animation don't work.

 
    gsap.to(document.querySelectorAll(".prev i.animation"), {
        keyframes: [
            {
                duration: 0.2,
                x: -5,
            },
            {
                duration: 0.5,
                x: -3,
            },
            {
                duration: 0.2,
                x: -5,
            },
            {
                duration: 0.5,
                x: 0,
            },
        ],
    });
Link to comment
Share on other sites

Hi there,

 

Can you please start a new thread with a minimal demo. Thank you!

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