React-Spring-2 useTransition() update style, useGesture() drag, SVG display and useSpring() animation
//useTransition() leaves-> enter on useState() change
//exitBeforeEnter finishes the leave before the enter
const [mio, setMio] = useState(["another"])
const estilo = useTransition(mio, {
from: {
back: "transparent", long: "0%", lefto: "0%",
color: "black", opacity: 0, width: "20%"
},
enter: [
{ back: "pink", color: "green", long: "90%", lefto: "10%", width: "100%", opacity: 1 },
{ back: "orange", color: "blue", long: "50%", lefto: "50%" },
{ back: "red", color: "red", long: "0%", lefto: "100%" }
],
leave: [
{ width: "20%" ,opacity: 0 }
],
exitBeforeEnter: true,
config:{ duration: 1000 }
})
//We deconstruct and ...rest the custom style properties
//We get the translate--centered-text effect animating width/text-center
<>
{estilo(( {back, long, lefto, ...resto} , item) => (
<animated.div className="centra d-flex align-items-center" >
<animated.div
className="sfondo"
style={{backgroundColor: back, width: long, left: lefto}}
>
</animated.div>
<animated.div className="testo" style={resto}>
{item}
</animated.div>
</animated.div>
))}
</>

React use-gesture and useSpring()




Waving transitions with animated SVG filters and useSpring()


PreviousReact-Spring-1 useSpring(), config, To() interpolate render, useTransition(), React-use-measure.NextReact-Spring 3 useSpringValue(), useChain(), useTrail() indeterpolation and Parallax.
Last updated