[bug]: Shorthands don't merge with transform values

Open
#1,913 9 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend, web-dev

Research direction

Reproduce the example with @react-spring/web and useSpring, starting with a from transform string and a to shorthand. Trace how transform values and shorthands are parsed and combined. Done means the shorthand is merged with the initial transform value, with coverage for this reproduction.

Written by the indexing model from the issue text.

Description

template: request
Which react-spring target are you using?
  • @react-spring/web
  • @react-spring/three
  • @react-spring/native
  • @react-spring/konva
  • @react-spring/zdog
What version of react-spring are you using?

9.4.5

What's Wrong?

(You probably know this one already, so please ignore if it is on a to-do list already.)

If I want to go from one transform value to another, with the library, I can't use shorthands in the to value, if I am starting off with a from value (which cannot have shorthands).

So the only way you can really go if you have a from transform string is to another transform string.

Is this by design? Not sure this is a bug. But since I spent a bunch of time learning this lesson, thought I'd share it.

To Reproduce
import { useSpring } from 'react-spring'

const [props, api] = useSpring(() => {
  from: { transform: 'scale3d(0.1, 0.1, 0.1) translate3d(0, -1000px, 0)' }
  to: { scale3d: '0.475 0.475 0.475' }
})

return <animated.div style={{props}} />
Expected Behaviour

For the shorthands to merge with the initial transform value in coming up with a final value.

Link to repo
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.