aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/docs/plugins/menu.ts
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-19 17:50:02 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-19 17:50:02 +0800
commit56a6240bf700ac307342ed494d8bfbabe5c822dc (patch)
tree0b1288a2ec1cbb538c11f4c122b6a97b9c55a05f /docs/plugins/menu.ts
parent3adc965dd09490b7efa1cce9f09b0a3b30970277 (diff)
downloadHydroRoll-56a6240bf700ac307342ed494d8bfbabe5c822dc.tar.gz
HydroRoll-56a6240bf700ac307342ed494d8bfbabe5c822dc.zip
✨docs init
Diffstat (limited to 'docs/plugins/menu.ts')
-rw-r--r--docs/plugins/menu.ts48
1 files changed, 0 insertions, 48 deletions
diff --git a/docs/plugins/menu.ts b/docs/plugins/menu.ts
deleted file mode 100644
index 82512c3..0000000
--- a/docs/plugins/menu.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-export default defineNuxtPlugin((ctx: any) => {
- // Menu visible reference
- const visible = ref(false)
-
- // Open the menu
- const open = () => (visible.value = true)
-
- // Close the menu
- const close = () => (visible.value = false)
-
- // Toggle the menu (useful for one-off buttons)
- const toggle = () => (visible.value = !visible.value)
-
- // Watch route change, close on change
- ctx.$router.afterEach(() => setTimeout(close, 50))
-
- // Watch visible and remove overflow so the scrollbar disappears when menu is opened
- if (process.client) {
- watch(
- visible,
- (isVisible) => {
- const html = document.documentElement
-
- if (isVisible) {
- html.style.overflow = 'hidden'
- } else {
- setTimeout(() => {
- html.style.overflow = ''
- }, 100) /* had to put it, because of layout shift on leave transition */
- }
- },
- {
- immediate: true
- }
- )
- }
-
- return {
- provide: {
- menu: {
- visible,
- close,
- open,
- toggle
- }
- }
- }
-})