chenglou/react-motion

Add section to the README about generic usage of interpolated value

Open

#494 geöffnet am 25. Sept. 2017

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.160 Forks)batch import
docshelp wanted

Repository-Metriken

Stars
 (21.646 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Put is somewhere at the top.

Make sure it is clear that styles prop is not working with, well, actually styles, but gives you ability to use value to derive all other values of your styles.

See https://github.com/chenglou/react-motion/issues/304#issuecomment-331750756

React motion does not operate "style" (I agree that is a misleading name for prop). It only applies function over any number you pass. This way it can stay minimal and you have all power to interpolate any number-related values.

<Motion defaultStyle={{whatever: 0}} style={{whatever: spring(1)}}>
  {({whatever}) => (
    <div style={{color: `rgb(${255 * whatever}, ${255 * whatever}, ${255 * whatever})`}}>
      Hey, I'm transitioning color!
    </div>
  )}
</Motion>

Related:

Contributor Guide