I encounter this problem. I use GSAP in react project to do some complicated animation. I want to ask that how can I clear the style applied on the DOM whenever the component re-render. It still keeps the old state which is the tl.reverse(). I set it it to Null again and re-define but i doesnt work. I'm also new to react. Below is code. Hope anyone can help
componentDidMount () {
this.menu_init()
this.cta_animation_init()
// this.cta_animation_active()
this.hover_effect()
$(window).on('scroll', function () {
var t = $(window).scrollTop()
if ((t > 0 && self.state.currentPos < t) || (t > self.state.min_height && self.state.currentPos > t) || $(window).width() <= 1020) {
self.menu_scroll()
} else {
self.menu_scrolling()
}
self.state.currentPos = t
})
}
componentWillUnmount()
{
}
menu_init () {
const tl = new TimelineMax({paused: true});
tl.to('.top-nav', 0.3, {y: '-165px', ease: Power0.easeNone})
.to('.burger-nav-bg, .burger-nav-button', 0.1, {opacity: 1, scale: 1}, '-=.3')
.staggerTo('.burger-nav-bar', 0.1, {left: '13px'}, '-=.1')
this.setState({tl:tl})
}
menu_scroll () {
this.state.tl.play()
}
menu_scrolling () {
this.state.tl.reverse()
}