Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Fix #76. Ensure controller API only operates on elements animated by corresponding hook. #80

Merged
merged 5 commits into from
Jul 28, 2020

Conversation

parkerziegler
Copy link
Contributor

Fix #76

This PR fixes a 🐛 introduced by v0.6.1. In the creation of our use<Force>Group hooks we introduced the concept of using a Set of animatingElements to manage handling multiple animating elements at once. This worked out great, but our Set was scoped at the module level rather than at the function level. This meant that, if you had multiple renature hooks running at the same time in the same React tree, the stop, start, and pause functions returned by any one of those hooks would act on all animating elements.

This PR fixes that by moving our animatingElements Set inside of function scope. This means each hook gets its own Set and manages its own instance of requestAnimationFrame. This is good – we want separate hook calls to maintain fully isolated state and behavior.

There are a few additional changes in here to improve our types and begin to DRY out some of the behavior of these hooks to make it easier to maintain moving forward 💪 Hoping to shave a few bytes with these changes!

@parkerziegler parkerziegler force-pushed the fix/controller-scope branch from 8ac8618 to 541003a Compare July 26, 2020 18:37
@parkerziegler parkerziegler merged commit 4983a07 into saturn Jul 28, 2020
@parkerziegler parkerziegler deleted the fix/controller-scope branch July 28, 2020 22:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

controller.start, controller.pause, and controller.stop will act on all animations.
2 participants