@brillout/docpress 0.15.13-commit-f8fc961 → 0.15.13-commit-39924f0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Layout.tsx +9 -17
- package/MenuModal/toggleMenuModal.ts +35 -8
- package/MenuModal.tsx +3 -3
- package/package.json +1 -1
- package/utils/getViewportWidth.ts +2 -2
package/Layout.tsx
CHANGED
|
@@ -15,7 +15,12 @@ import { getNavItemsWithComputed, NavItem, NavItemComponent } from './NavItemCom
|
|
|
15
15
|
import { parseMarkdownMini } from './parseMarkdownMini'
|
|
16
16
|
import { usePageContext } from './renderer/usePageContext'
|
|
17
17
|
import { ExternalLinks } from './ExternalLinks'
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
closeMenuModalOnMouseLeaveToggle,
|
|
20
|
+
ignoreHoverOnTouchStart,
|
|
21
|
+
openMenuModalOnMouseEnter,
|
|
22
|
+
toggleMenuModal,
|
|
23
|
+
} from './MenuModal/toggleMenuModal'
|
|
19
24
|
import { MenuModal } from './MenuModal'
|
|
20
25
|
import { autoScrollNav_SSR } from './autoScrollNav'
|
|
21
26
|
import { initializeJsToggle_SSR } from './code-blocks/hooks/useSelectCodeLang'
|
|
@@ -562,7 +567,6 @@ function isProjectNameShort(name: string) {
|
|
|
562
567
|
return name.length <= 4
|
|
563
568
|
}
|
|
564
569
|
|
|
565
|
-
let onMouseIgnore: ReturnType<typeof setTimeout> | undefined
|
|
566
570
|
type PropsDiv = React.HTMLProps<HTMLDivElement>
|
|
567
571
|
function MenuToggleMain(props: PropsDiv) {
|
|
568
572
|
return (
|
|
@@ -607,20 +611,12 @@ function MenuToggle({ menuId, ...props }: PropsDiv & { menuId: number }) {
|
|
|
607
611
|
toggleMenuModal(menuId)
|
|
608
612
|
}}
|
|
609
613
|
onMouseEnter={() => {
|
|
610
|
-
|
|
611
|
-
if (isMobileNav()) return
|
|
612
|
-
openMenuModal(menuId)
|
|
614
|
+
openMenuModalOnMouseEnter(menuId)
|
|
613
615
|
}}
|
|
614
616
|
onMouseLeave={() => {
|
|
615
|
-
|
|
616
|
-
if (isMobileNav()) return
|
|
617
|
-
coseMenuModalOnMouseLeave(menuId)
|
|
618
|
-
}}
|
|
619
|
-
onTouchStart={() => {
|
|
620
|
-
onMouseIgnore = setTimeout(() => {
|
|
621
|
-
onMouseIgnore = undefined
|
|
622
|
-
}, 1000)
|
|
617
|
+
closeMenuModalOnMouseLeaveToggle(menuId)
|
|
623
618
|
}}
|
|
619
|
+
onTouchStart={ignoreHoverOnTouchStart}
|
|
624
620
|
>
|
|
625
621
|
<Style>{getAnimation()}</Style>
|
|
626
622
|
{props.children}
|
|
@@ -728,7 +724,3 @@ function MenuIcon() {
|
|
|
728
724
|
</svg>
|
|
729
725
|
)
|
|
730
726
|
}
|
|
731
|
-
|
|
732
|
-
function isMobileNav() {
|
|
733
|
-
return window.innerWidth <= viewTablet
|
|
734
|
-
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { toggleMenuModal }
|
|
2
|
-
export { openMenuModal }
|
|
3
|
-
export { keepMenuModalOpen }
|
|
4
2
|
export { closeMenuModal }
|
|
5
|
-
|
|
3
|
+
// Hover handling
|
|
4
|
+
export { ignoreHoverOnTouchStart }
|
|
5
|
+
export { openMenuModalOnMouseEnter }
|
|
6
|
+
export { keepMenuModalOpenOnMouseOver }
|
|
7
|
+
export { closeMenuModalOnMouseLeave }
|
|
8
|
+
export { closeMenuModalOnMouseLeaveToggle }
|
|
6
9
|
|
|
7
10
|
import { viewTablet } from '../Layout'
|
|
8
11
|
import { getHydrationPromise } from '../renderer/getHydrationPromise'
|
|
@@ -11,9 +14,6 @@ import { isBrowser } from '../utils/isBrowser'
|
|
|
11
14
|
|
|
12
15
|
initScrollListener()
|
|
13
16
|
|
|
14
|
-
function keepMenuModalOpen() {
|
|
15
|
-
open()
|
|
16
|
-
}
|
|
17
17
|
function openMenuModal(menuNavigationId: number) {
|
|
18
18
|
open(menuNavigationId)
|
|
19
19
|
}
|
|
@@ -72,7 +72,8 @@ let toggleLock:
|
|
|
72
72
|
timeoutAction: NodeJS.Timeout
|
|
73
73
|
}
|
|
74
74
|
| undefined
|
|
75
|
-
function
|
|
75
|
+
function closeMenuModalOnMouseLeaveToggle(menuId: number) {
|
|
76
|
+
if (ignoreHover()) return
|
|
76
77
|
clearTimeout(toggleLock?.timeoutAction)
|
|
77
78
|
const timeoutAction = setTimeout(action, 100)
|
|
78
79
|
toggleLock = {
|
|
@@ -111,7 +112,7 @@ function toggleMenuModal(menuId: number) {
|
|
|
111
112
|
closeMenuModal()
|
|
112
113
|
} else {
|
|
113
114
|
openMenuModal(menuId)
|
|
114
|
-
if (
|
|
115
|
+
if (isMobileNav()) autoScroll()
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -137,3 +138,29 @@ function findCollapsibleEl(navLink: HTMLElement | undefined) {
|
|
|
137
138
|
}
|
|
138
139
|
return null
|
|
139
140
|
}
|
|
141
|
+
|
|
142
|
+
function closeMenuModalOnMouseLeave() {
|
|
143
|
+
if (ignoreHover()) return
|
|
144
|
+
closeMenuModal()
|
|
145
|
+
}
|
|
146
|
+
function keepMenuModalOpenOnMouseOver() {
|
|
147
|
+
if (ignoreHover()) return
|
|
148
|
+
open()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let isTouchStart: ReturnType<typeof setTimeout> | undefined
|
|
152
|
+
function ignoreHoverOnTouchStart() {
|
|
153
|
+
isTouchStart = setTimeout(() => {
|
|
154
|
+
isTouchStart = undefined
|
|
155
|
+
}, 1000)
|
|
156
|
+
}
|
|
157
|
+
function openMenuModalOnMouseEnter(menuId: number) {
|
|
158
|
+
if (ignoreHover()) return
|
|
159
|
+
openMenuModal(menuId)
|
|
160
|
+
}
|
|
161
|
+
function ignoreHover() {
|
|
162
|
+
return isTouchStart || isMobileNav()
|
|
163
|
+
}
|
|
164
|
+
function isMobileNav() {
|
|
165
|
+
return getViewportWidth() <= viewTablet
|
|
166
|
+
}
|
package/MenuModal.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { viewDesktop, viewTablet } from './Layout'
|
|
|
7
7
|
import { ExternalLinks } from './ExternalLinks'
|
|
8
8
|
import { Style } from './utils/Style'
|
|
9
9
|
import { NavigationWithColumnLayout } from './MenuModal/NavigationWithColumnLayout'
|
|
10
|
-
import { closeMenuModal,
|
|
10
|
+
import { closeMenuModal, closeMenuModalOnMouseLeave, keepMenuModalOpenOnMouseOver } from './MenuModal/toggleMenuModal'
|
|
11
11
|
import { EditLink } from './EditLink'
|
|
12
12
|
|
|
13
13
|
function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
@@ -27,8 +27,8 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
|
27
27
|
transitionProperty: 'opacity',
|
|
28
28
|
transitionTimingFunction: 'ease',
|
|
29
29
|
}}
|
|
30
|
-
onMouseOver={
|
|
31
|
-
onMouseLeave={
|
|
30
|
+
onMouseOver={keepMenuModalOpenOnMouseOver}
|
|
31
|
+
onMouseLeave={closeMenuModalOnMouseLeave}
|
|
32
32
|
>
|
|
33
33
|
<div
|
|
34
34
|
id="menu-modal-scroll-container"
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function getViewportWidth(): number {
|
|
2
|
-
//
|
|
3
|
-
return document.documentElement.
|
|
2
|
+
// Width without scrollbar
|
|
3
|
+
return document.documentElement.scrollWidth
|
|
4
4
|
}
|