Created
February 4, 2019 13:16
-
-
Save jmn/b642cd0261b88003e5d385d9ffc5b4f3 to your computer and use it in GitHub Desktop.
Why does this not animate?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { Transition } from "react-spring"; | |
import "./App.css"; | |
class App extends Component { | |
state = { | |
items: [1, 2, 3], | |
toggleDiv: false | |
}; | |
render() { | |
return ( | |
<div id="root"> | |
<header className="App-header"> | |
<div>Hello</div> | |
<Transition | |
items={this.state.items} | |
keys={item => item} | |
from={{ transform: "translate3d(0,-40px,0)" }} | |
enter={{ transform: "translate3d(0,0px,0)" }} | |
leave={{ transform: "translate3d(0,-40px,0)" }} | |
trail={20} | |
> | |
{item => | |
this.state.toggleDiv && (props => <div style={props}>{item}</div>) | |
} | |
</Transition> | |
<button onClick={() => this.setState({ toggleDiv: true })}> | |
Hej | |
</button> | |
</header> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment