On update loaded animation. Fixed.

This commit is contained in:
2018-06-06 11:19:38 -07:00
parent b4dc4defb6
commit 9d846a7bd8
2 changed files with 11 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{
"name": "react-animated-menus",
"version": "1.0.6",
"version": "1.0.7",
"description": "React component that mounts three dot button that morphs into a menu by clicking on it.",
"main": "./lib/index.js",
"license": "MIT",

View File

@ -38,35 +38,31 @@ class App extends Component {
* }
*/
this.state = {
id: this.getId(),
open: false
}
this.open = false;
this.id = this.getId();
}
componentDidMount() {
//Event listener for click
document.addEventListener("click", (event) => {
const id = this.state.id;
const open = this.state.open;
const id = this.id;
const open = this.open;
if(event.target.closest('#'+id) && !open) {
this.setState({
open: true
});
this.open = true;
animate();
}
if(!event.target.closest('#'+id) && open) {
this.setState({
open: false
});
this.open = false;
animate();
}
});
}
componentDidUpdate() {
animate() {
const id = this.state.id;
//Targets that will be triggered
@ -76,7 +72,7 @@ class App extends Component {
if(this.state.open) {
if(this.open) {
var animation = anime.timeline();
//Display buttons