Create new toggle menu component
This commit is contained in:
25
js/components/toggle_menu.js
Normal file
25
js/components/toggle_menu.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import ToggleMixin from '../mixins/toggle'
|
||||
|
||||
export default {
|
||||
name: 'toggleMenu',
|
||||
|
||||
mixins: [ToggleMixin],
|
||||
|
||||
methods: {
|
||||
toggle: function(e) {
|
||||
if (this.$el.contains(e.target)) {
|
||||
this.isVisible = !this.isVisible
|
||||
} else {
|
||||
this.isVisible = false
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
document.addEventListener('click', this.toggle)
|
||||
},
|
||||
|
||||
beforeDestroy: function() {
|
||||
document.removeEventListener('click', this.toggle)
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user