pmndrs / pmndrs/react-spring

Specify useTrail attached origin index

Open
#644 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind: request
Dominant language
TypeScript
Stars
29.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

🚀 Feature Proposal

useTrail uses useSprings under the hood and the - I believe - undocumented attach attribute to attach controllers from the first spring to the last. I think it would be useful to allow users specify which index should useTrail use as its origin.

Motivation

I made a small carousel lib with staggered animation: https://github.com/dbismut/react-soft-slider

In my situation, I needed slides to trail the dragged slide, which index can obviously vary. To make that happen, I reused the source code from useTrail and adapted to my needs. I'm not exactly sure what would be the best API for this though, possibly set({..., attachedIndex: index }). I'm also wondering if useTrail could also share the same set(i => ({...})) as useSprings.

Example

Heavily inspired from the example on react-use-gesture: https://codesandbox.io/s/nwj6597vq4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the useTrail and useSprings entry points, including how the undocumented attach attribute selects the origin controller. Review the existing hook API and the linked carousel use case before deciding whether a selectable origin and shared set callback fit the design. Done means an agreed API is implemented and its behavior is covered by appropriate tests or examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.