[Request] Be able to set spring config per value

Open
#1,803 2 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Start by reproducing the per-value configuration need in the linked CodeSandbox and reading the existing useSpring API behavior. Define how separate opacity and x configurations should work within one spring and verify that one API can control both values with their individual settings.

Written by the indexing model from the issue text.

Description

kind: request

🚀 Feature Proposal

The idea is to be able to set a spring config per value in a single useSpring.

Motivation + Example

I like to use a single useSpring per component where possible and when doing more complex motion design I need individual values to have their own spring config. This especially becomes important when the spring config is modified depending on the state of the app and user interactions. For example, I may have an opacity value that I want to always transition with a linear duration but an x value that toggles from being stiff to wobbly depending on its direction of motion (open or close).

Currently I have to make two springs to handle this case and then use their apis in sync.

Note: I thought I could use a useSpringRef for a single api to control both springs but I couldn't figure out how to change the config for individual springs this way.

Here is a sandbox: https://codesandbox.io/s/dreamy-turing-3kpom?file=/src/App.js

Dominant language
TypeScript
Stars
29.3k
Forks
1.2k
Avg merge
3d 15h
Merged PRs (30d)
17

Getting set up

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.

More from pmndrs/react-spring

All issues in pmndrs/react-spring

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.