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

Animate the like button #5033

Merged
merged 8 commits into from
Aug 30, 2024
Merged

Animate the like button #5033

merged 8 commits into from
Aug 30, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Aug 30, 2024

Inspired by #4405 but a slightly different animation (inspired by the one in examples on the React homepage).

web.mov
ios.mov
android.mov

Copy link

render bot commented Aug 30, 2024

Copy link

github-actions bot commented Aug 30, 2024

Old size New size Diff
7.09 MB 7.09 MB 503 B (0.01%)

Copy link
Contributor

@haileyok haileyok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks great!

Comment on lines 122 to 142
if (PlatformInfo.getIsReducedMotionEnabled()) {
likeAnimValue.value = 1
} else {
likeAnimValue.value = withTiming(1, {
duration: 400,
easing: Easing.out(Easing.cubic),
})
}
Copy link
Contributor

@haileyok haileyok Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With these, you can tell the withTiming call to reduce motion if needed.

https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility/#reduced-motion-in-animations

Suggested change
if (PlatformInfo.getIsReducedMotionEnabled()) {
likeAnimValue.value = 1
} else {
likeAnimValue.value = withTiming(1, {
duration: 400,
easing: Easing.out(Easing.cubic),
})
}
likeAnimValue.value = withTiming(1, {
duration: 400,
easing: Easing.out(Easing.cubic),
reduceMotion: ReduceMotion.System,
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't work :(

Comment on lines +10 to +12
Easing,
interpolate,
SharedValue,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Easing,
interpolate,
SharedValue,
Easing,
interpolate,
ReduceMotion,
SharedValue,

@@ -45,6 +54,7 @@ import {
Heart2_Stroke2_Corner0_Rounded as HeartIconOutline,
} from '#/components/icons/Heart2'
import * as Prompt from '#/components/Prompt'
import {PlatformInfo} from '../../../../../modules/expo-bluesky-swiss-army'
Copy link
Contributor

@haileyok haileyok Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import {PlatformInfo} from '../../../../../modules/expo-bluesky-swiss-army'

@surfdude29
Copy link
Contributor

Just tried this out on the preview branch, it looks so good! Great job 👌🙏

Copy link
Member

@mozzius mozzius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only briefly had a look on web but this is amazing, 10/10

@gaearon gaearon merged commit ed232e6 into main Aug 30, 2024
6 checks passed
@gaearon gaearon deleted the like-anim branch August 30, 2024 22:16
@gaearon gaearon mentioned this pull request Aug 30, 2024
haileyok added a commit that referenced this pull request Aug 31, 2024
* Animate the like button

* Respect reduced motion

* Move like count into animated component

* Animate text

* Fix layout on Android

* Animate text backwards too

* Fix bad copypasta

* Reflect nonlocal updates to animated values

(cherry picked from commit ed232e6)
haileyok added a commit that referenced this pull request Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants