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

Adding animation events to motion value #1826

Merged
merged 3 commits into from Dec 15, 2022
Merged

Conversation

mattgperry
Copy link
Collaborator

Implements #1824

This PR adds a new event subscription method to motion values, .on(), along with three new motion value events, "animationStart", "animationComplete" and "animationCancel".

This allows multiple event handlers to be attached to the same motion value.

CHANGELOG.md Outdated
### Added

- `.on()` event method to `MotionValue`.
- `"animationStart"`, `"animationComplete"`, and `"animationCancel"` events for `MotionValue`.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about "change"?

const value = motionValue(0)
const callback = jest.fn()

value.on("change", callback)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we keeping the old API around?

Comment on lines +160 to 174
* @deprecated
*/
onChange(subscription: Subscriber<V>): () => void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess there's my answer 😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ha. I think it's so widely used by us I won't even throw in a warning yet. I'm gonna drop it in the docs and then revisit in 6 months or so, maybe add a warning then.

@mattgperry mattgperry added the automerge Land this PR label Dec 15, 2022
@mergetron mergetron bot merged commit e186f74 into main Dec 15, 2022
@mergetron mergetron bot deleted the fix/motion-value-events branch December 15, 2022 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Land this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants