Jump to content
Search Community

Reverse in React

monema test
Moderator Tag

Recommended Posts

I know i should make a codepen, but it's gatsbyjs and i don't know how to replicate all the things.
I just triyng to reverse the

timeline.current

in this component
Play is ok, but the reverse jump directly to first frame animation (which is autoalpha: .0) whitout tweening anithing.
...and i'm feeling blue...

import * as React from "react"
import { gsap } from 'gsap'
import { useRef, useEffect } from 'react'
function Scritte({ app, mouseOut }) {
    const scritte = useRef()
    const timeline = useRef()

    timeline.current = gsap.timeline({ paused: true })
    timeline.current
    .add("start")
    .fromTo(scritte.current, { autoAlpha: .0 },{ autoAlpha: 1 })
    .add("stop")

    
    useEffect(() => {
     app ? timeline.current.play() : timeline.current.reverse()
    }, [app])



    return (
        <div className="scritte-home" ref={scritte}>{app}</div>
    )
}

export default Scritte

Thank you so much for any kind of help

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