what does the xys in config mean? #1545
-
i found this sample code, but i cant understand what xys means? can someone explain to me? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
const trans = (x, y, s) => `perspective(600px) rotateX(${x}deg) rotateY(${y}deg) scale(${s})`; The example you've shared uses an old version of |
Beta Was this translation helpful? Give feedback.
xys
is the name of an arbitrary prop in theuseSpring
hook in the form of an array. If you passed it directly to the animated component it wouldn't do anything because it doesn't relate to a css prop, hence why weinterpolate
the value:props.xys.to(trans)
, where trans is a function returning a string of CSS props:The example you've shared uses an old version of
react-spring
but i've updated it to the most up to date, see: https://codesandbox.io/s/tilt-card-with-react-spring-hooks-forked-cqx46?file=/src/index.js