From be3336a18d5bd2a798ad3b18b5e21d45c50392b8 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Mon, 5 Dec 2022 00:04:01 +0100 Subject: [PATCH] Hide menu when navigating page --- resources/js/app.js | 3 +++ resources/js/layouts/AppLayout.vue | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/resources/js/app.js b/resources/js/app.js index 921dbcd3..704d5e8b 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,5 +1,6 @@ import Vue from 'vue'; import {App as InertiaApp, plugin, Link as ILink} from '@inertiajs/inertia-vue'; +import {Inertia} from '@inertiajs/inertia'; import SvgSprite from './components/SvgSprite.js'; import VPages from './components/VPages.vue'; @@ -32,6 +33,8 @@ const el = document.getElementById('app'); Vue.mixin(hasModule); Vue.component('ILink', ILink); +Inertia.on('start', (event) => window.dispatchEvent(new Event('inertiaStart'))); + new Vue({ render: (h) => h(InertiaApp, { diff --git a/resources/js/layouts/AppLayout.vue b/resources/js/layouts/AppLayout.vue index dfcd5a44..a6ec8da5 100644 --- a/resources/js/layouts/AppLayout.vue +++ b/resources/js/layouts/AppLayout.vue @@ -150,8 +150,15 @@ export default { }, }, created() { + var _self = this; window.addEventListener('resize', this.menuListener); this.menuListener(); + + window.addEventListener('inertiaStart', (e) => { + _self.menuVisible = false; + _self.searchVisible = false; + _self.menuOverflowVisible = false; + }); }, };