diff --git a/docs/example/navbarDocs.vue b/docs/example/navbarDocs.vue index 34f7b0ea..b79bd66e 100644 --- a/docs/example/navbarDocs.vue +++ b/docs/example/navbarDocs.vue @@ -57,6 +57,13 @@

+ +
+

collapse

+

+

Return if the menu was collapsed, e.g. on click of menu pick or click outside of menu.

+
+
diff --git a/src/Navbar.vue b/src/Navbar.vue index 81fd1b7e..54485170 100644 --- a/src/Navbar.vue +++ b/src/Navbar.vue @@ -74,6 +74,7 @@ export default { $dropdown.each(content => { if (!content.contains(e.target)) content.classList.remove('open') + this.$emit('collapse') }) }) } @@ -82,9 +83,9 @@ export default { } $(this.$el).on('click touchstart','li:not(.dropdown)>a', e => { - setTimeout(() => { this.collapsed = true }, 200) + setTimeout(() => { this.collapsed = true; this.$emit('collapse'); }, 200) }).onBlur(e => { - if (!this.$el.contains(e.target)) { this.collapsed = true } + if (!this.$el.contains(e.target)) { this.collapsed = true; this.$emit('collapse') } }) let height = this.$el.offsetHeight if (this.placement === 'top') {