Only animate the like icon when from an actual toggle (#5096)
This commit is contained in:
parent
bd42f770b8
commit
0014d4363f
5 changed files with 20 additions and 9 deletions
|
@ -91,13 +91,15 @@ export function CountWheel({
|
|||
likeCount,
|
||||
big,
|
||||
isLiked,
|
||||
isToggle,
|
||||
}: {
|
||||
likeCount: number
|
||||
big?: boolean
|
||||
isLiked: boolean
|
||||
isToggle: boolean
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const shouldAnimate = !useReducedMotion()
|
||||
const shouldAnimate = !useReducedMotion() && isToggle
|
||||
const shouldRoll = decideShouldRoll(isLiked, likeCount)
|
||||
|
||||
// Incrementing the key will cause the `Animated.View` to re-render, with the newly selected entering/exiting
|
||||
|
|
|
@ -39,13 +39,15 @@ export function CountWheel({
|
|||
likeCount,
|
||||
big,
|
||||
isLiked,
|
||||
isToggle,
|
||||
}: {
|
||||
likeCount: number
|
||||
big?: boolean
|
||||
isLiked: boolean
|
||||
isToggle: boolean
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const shouldAnimate = !useReducedMotion()
|
||||
const shouldAnimate = !useReducedMotion() && isToggle
|
||||
const shouldRoll = decideShouldRoll(isLiked, likeCount)
|
||||
|
||||
const countView = React.useRef<HTMLDivElement>(null)
|
||||
|
|
|
@ -71,13 +71,15 @@ const circle2Keyframe = new Keyframe({
|
|||
export function AnimatedLikeIcon({
|
||||
isLiked,
|
||||
big,
|
||||
isToggle,
|
||||
}: {
|
||||
isLiked: boolean
|
||||
big?: boolean
|
||||
isToggle: boolean
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const size = big ? 22 : 18
|
||||
const shouldAnimate = !useReducedMotion()
|
||||
const shouldAnimate = !useReducedMotion() && isToggle
|
||||
|
||||
return (
|
||||
<View>
|
||||
|
|
|
@ -41,13 +41,15 @@ const circle2Keyframe = [
|
|||
export function AnimatedLikeIcon({
|
||||
isLiked,
|
||||
big,
|
||||
isToggle,
|
||||
}: {
|
||||
isLiked: boolean
|
||||
big?: boolean
|
||||
isToggle: boolean
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const size = big ? 22 : 18
|
||||
const shouldAnimate = !useReducedMotion()
|
||||
const shouldAnimate = !useReducedMotion() && isToggle
|
||||
const prevIsLiked = React.useRef(isLiked)
|
||||
|
||||
const likeIconRef = React.useRef<HTMLDivElement>(null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue