Jump to content
Search Community

kill hover animation in gsap matchmedia // react

Sherlok test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hello,

The example is located here https://codesandbox.io/s/serene-lena-5o2lhi?file=/src/App.js

When the width suitable for desktop the hover animation plays well. But I want to turn the animation for mobile devices. So, on mobile devices I got Cannot read properties of undefined (reading 'play'). I try to reset timeline or use kill but it doesn't work for me. What is the best way to do it? 

Thanks

Link to comment
Share on other sites

  • Solution

Hi,

 

Just a syntax error:

// Syntax in the breakpoint here
mm.add("max-width: 1023px", () => {
  tlMainLogoRef.current = gsap
    .timeline({ paused: true })
    .to(".mainLogo", { rotate: 0, scale: 0 }, "<");
});

You forgot the parenthesis around the breakpoint:

mm.add("(max-width: 1023px)", () => {
  tlMainLogoRef.current = gsap
    .timeline({ paused: true })
    .to(".mainLogo", { rotate: 0, scale: 0 }, "<");
});

Happy Tweening!

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