[feat]: trail onComplete event
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 29.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
A clear and concise description of what the feature is
A onComplete (or similar) event that triggers when ALL parts of a trail has completed. This is analogous to the onRest event on a single spring.
Why should this feature be included?
The onRest is a useful event for single springs. It would be great to have a similar event on trails.
Please provide an example for how this would work
onComplete should trigger when all springs from a single trail has reached rest.
I am achieving a similar effect by using the following code today.
const onComplete = () => console.log('trail completed')
const trail = useTrail(baseSquares.length, {
to: {"rotation-x": -Math.PI / 2},
from: {"rotation-x": 0},
onRest: (_, w) => {
if (w.springs["rotation-x"]._priority === offsets.length - 1) onComplete()
},
})
CSB https://codesandbox.io/s/quirky-visvesvaraya-8kbukr?file=/src/App.js
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the useTrail API and its existing onRest behavior, using the linked CodeSandbox as the behavioral example. Define completion for a trail as the point when all springs from one trail have reached rest, and verify that the new event fires once for that condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100