Added a restart function to the Observer object, useful when using react-router in a react app #10
+13
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I was having an issue when using
intersect-once
, I've been using this plugin in combination with tailwindcss-motion in order to play animation only once on scroll in my react app.the issue
When switching between routes on the frontend using
react-router
below elements animations will be played too early as if the user scrolled on them which resulted in animation not playing properly for the user since it was "already intersected" which shouldn't happen, in reality the user didn't scroll on those elements, it's supposed to reset since it's a new route.the fix
I thought why not implementing a tiny restart function that will be triggered on each route change, it removes existing observers before attaching a new one, simple yet was an effective solution to my issue when routing in my react app, and I felt sharing this might be useful for other people that are facing the same issue.