chenglou / chenglou/react-motion

prevInterpolatedStyles has an empty array in TransitionMotion

Open
#345 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
21.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I am trying to include TransitionMotion with a staggered effect.. I am using the function format for the styles prop to have the staggered effect.. But the prevInterpolatedStyles is always giving me an empty array.. I am not sure what I've missed and can't get it to work. Have a look at the code below...

This is the one where prevInterpolatedStyles is always returning an empty array.

` ({data: obj, key: index+"", style:{s: 0}}))}
styles={(prevInterpolatedStyles) => {console.log(prevInterpolatedStyles); return prevInterpolatedStyles.map((_, i) => {
return i === 0
? {data: _, key: i+"", style:{s: spring(this.state.show ? 1 : 0)}}
: {data: _, key: i+"", style:{s: spring(this.state.show ? prevInterpolatedStyles[i - 1].style.s : 0)}}
})}}>/* Elements to be animated */`

This one works fine without Staggering effect.

` ({data: obj, key: index+"", style:{s: 0}}))}
styles={this.state.data.map((obj,index) => ({data: obj, key: index+"", style:{s: spring(this.state.show ? 1 : 0)}}))}> /* Elements to be animated */`

Thanks!!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the provided TransitionMotion examples, focusing on the styles prop function and the prevInterpolatedStyles value. Compare the working direct styles array with the staggered version and trace when the previous interpolated styles are supplied. Done means the staggered example receives the expected array and animates correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.