diff --git a/package.json b/package.json index d474e03..b0cc49f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/Menu.js b/src/components/Menu.js index 90cb87e..1048bc7 100644 --- a/src/components/Menu.js +++ b/src/components/Menu.js @@ -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