File tree 1 file changed +6
-10
lines changed
packages/gitbook/src/components/TableOfContents 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,19 @@ import React from 'react';
4
4
5
5
import { ClassValue , tcls } from '@/lib/tailwind' ;
6
6
7
- const TOCScrollContainerRefContext = React . createContext < React . RefObject < HTMLDivElement > | null > ( null ) ;
7
+ const TOCScrollContainerRefContext = React . createContext < React . RefObject < HTMLDivElement > | null > (
8
+ null ,
9
+ ) ;
8
10
9
11
function useTOCScrollContainerRefContext ( ) {
10
12
const ctx = React . useContext ( TOCScrollContainerRefContext ) ;
11
13
if ( ! ctx ) {
12
- throw new Error ( " Context `TOCScrollContainerRefContext` must be used within Provider" ) ;
14
+ throw new Error ( ' Context `TOCScrollContainerRefContext` must be used within Provider' ) ;
13
15
}
14
16
return ctx ;
15
17
}
16
18
17
- export function TOCScrollContainer ( props : {
18
- children : React . ReactNode ;
19
- className ?: ClassValue ;
20
- } ) {
19
+ export function TOCScrollContainer ( props : { children : React . ReactNode ; className ?: ClassValue } ) {
21
20
const { children, className } = props ;
22
21
const scrollContainerRef = React . createRef < HTMLDivElement > ( ) ;
23
22
@@ -67,8 +66,5 @@ function isOutOfView(tocItem: HTMLElement, tocContainer: HTMLElement) {
67
66
const tocItemTop = tocItem . offsetTop ;
68
67
const containerTop = tocContainer . scrollTop ;
69
68
const containerBottom = containerTop + tocContainer . clientHeight ;
70
- return (
71
- tocItemTop < containerTop ||
72
- tocItemTop > containerBottom
73
- ) ;
69
+ return tocItemTop < containerTop || tocItemTop > containerBottom ;
74
70
}
You can’t perform that action at this time.
0 commit comments