Jump to content
Search Community

Detect start and complete of reverse animation?

TheNomadicAspie test
Moderator Tag

Recommended Posts

Throughout my code, I increment and decrement state_dict.animation_counter at the start and finish of each animation, so I can ensure a user doesn't interrupt the animation until it completes.

 

I'm using a function hideButton to hide a button, and then showButton calls reverse()  to reverse the animation.

 

The problem is, I need to find a way to increment and decrement that variable at the start and finish of the reversal. I haven't been able to find a way to do this, is this possible? This is what I'm doing.

 

function hideButton(button, show = false, text_string = false, buttonFunction = false) {
	hide_left_button_tween = gsap.to(left_button, {
	x: -window.screen.width,
	ease: "none",
	duration: 0.5,
	paused: true,
	onStart() {
		state_dict.animation_counter++
	},
	onComplete() {
		state_dict.animation_counter--
	},
	})
}

function showButton(button, text_string = false, buttonFunction = false) {
	hide_left_button_tween.reverse()
}

 

Since I can't increment and decrement that counter, right now if a user interacts with my program during an animation, it halts the reversal of the animation. Any ideas?

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