Refactor: JS syntax

This commit is contained in:
Lucas Larroche 2021-11-08 00:06:11 +07:00
parent 5557876fce
commit 0c64ec721a
6 changed files with 129 additions and 211 deletions

View file

@ -18,25 +18,14 @@ export const toggleNavigation = {
},
onToggleClick() {
this.toggleLink.addEventListener(
'click',
function (event) {
event.preventDefault();
if (this.state == 'closed-on-mobile') {
this.state = 'open';
} else {
this.state = 'closed-on-mobile';
}
this.nav.removeAttribute('class');
this.nav.classList.add(this.state);
}.bind(this),
false
);
},
// Apply navigation state
applyState() {
this.toggleLink.addEventListener('click', event => {
event.preventDefault();
this.state == 'closed-on-mobile'
? this.state = 'open'
: this.state = 'closed-on-mobile';
this.nav.removeAttribute('class');
this.nav.classList.add(this.state);
}, false);
},
// Get state