Skip to content

Instantly share code, notes, and snippets.

@Nantris
Created February 1, 2020 20:46
Show Gist options
  • Save Nantris/7394d05e101c26b27f4704fc13145d80 to your computer and use it in GitHub Desktop.
Save Nantris/7394d05e101c26b27f4704fc13145d80 to your computer and use it in GitHub Desktop.
import React from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";
import { animated, useTrail } from "react-spring";
import "./styles.css";
const Box = styled(animated.div)`
background: black;
color: white;
display: inline-block;
width: 3rem;
margin-right: 1rem;
`;
function App() {
const nums = ["one", "two", "three"];
const trails = useTrail(nums.length, {
from: { transform: "scaleY(1)" },
to: [
{ transform: "scaleY(2)" },
{ transform: "scaleY(1)" },
{ transform: "scaleY(2)" },
{ transform: "scaleY(1)" },
{ transform: "scaleY(2)" },
{ transform: "scaleY(1)" },
{ transform: "scaleY(2)" },
{ transform: "scaleY(1)" }
]
});
return (
<div className="App">
<h1>react-spring useTrail 8.0.27</h1>
{trails.map((props, idx) => (
<Box style={props} key={nums[idx]}>
<h1>{nums[idx]}</h1>
</Box>
))}
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment