Skip to content

Trigger JS callback on keyframe #5887

Answered by MatiPl01
AdamGerthel asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

Referring to this section in docs, you can use keyframe animations only for layout entering/exiting animations. So, there is no way to manually control when the keyframe animation is executed.

If I understand your desired behavior properly, you could achieve a similar result by storing your players hp in the shared values and play the animation every time the hp shared value decreases. These values should be somehow accessible from in player components (e.g. via shared state, such as context).

// Shared state accessible from both players (e.g. PlayersContext)
const player1Hp = useSharedValue(100)
const player2Hp = useSharedValue(100)

// Player component
const { player1Hp: hp } = use…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@AdamGerthel
Comment options

@MatiPl01
Comment options

@AdamGerthel
Comment options

@MatiPl01
Comment options

Answer selected by AdamGerthel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants