Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated spring callback not called immediately after the animation finishes #20783

Closed
3 tasks done
MarkOSullivan94 opened this issue Aug 22, 2018 · 7 comments
Closed
3 tasks done
Labels
API: Animated Bug Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.

Comments

@MarkOSullivan94
Copy link

MarkOSullivan94 commented Aug 22, 2018

Environment

Environment:
OS: Linux 4.4
Node: 9.4.0
Yarn: Not Found
npm: 6.2.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: ^16.3.1 => 16.4.2
react-native: ^0.56.0 => 0.56.0

Description

This issue had been originally brought up back in 2015 but was never sorted #1951

There is a noticeable delay in the callback which is triggered after the animation ends, this is a major issue whenever you want to hide / show content once the animation is finished and so it would be great if this delay could be completely eliminated.

I have noticed that Animated.timing(...) does not have this delay after the animation has finished.

Reproducible Demo

I did try and get a expo snack demo working but wasn't able to.

Below is the code I use to setup the animation

let animation = Animated.timing(
			this.state.animation,
			{
				toValue: finalValue,
			}
);

animation.start(this._animationFinishCallback());

Below is the callback trigger when the animation finishes.

_animationFinishCallback = () => {
		console.log("animationFinish");
};
@stale
Copy link

stale bot commented Dec 21, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 21, 2018
@MarkOSullivan94
Copy link
Author

Not sure if this has been fixed, would be good if one of the React Native team could clarify.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 21, 2018
@sunnylqm
Copy link
Contributor

sunnylqm commented Dec 25, 2018

@MarkOSullivan94 My guess is that there are still tiny bouncy movements ongoing which are difficult for a human to perceive but indeed not zero on Maths. So you may feel it already end but actually not.

After a glance at the source code here, I guess that you may try to increase restSpeedThreshold and restDisplacementThreshold of spring to make it more "immediate" to end.

@khusmann
Copy link

khusmann commented Feb 5, 2019

@sunnylqm @MarkOSullivan94 hmmm, I tried fiddling with restSpeedThreshold and restDisplacementThreshold but am not really observing an effect. There is still a delay for the callback to run after the animation stops.

@MoOx
Copy link
Contributor

MoOx commented Apr 9, 2019

With something like restSpeedThreshold: 100, restDisplacementThreshold: 40 it can have a nice effect for an animation that cover an entire smartphone (eg: view swiped down to fold it a la Apple Music). Thanks for the pointer @sunnylqm

@satya164
Copy link
Contributor

Spring animations take a long time to fully settle. You can't notice the animation during the end because it's too slow, but it's still happening. You should be able to verify this by adding addListener on the animated value.

Closing because it's not a bug.

@devproivansurzhenko
Copy link

@MoOx You solution works pretty perfect in my case. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: Animated Bug Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants