File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,12 @@ export function Markdown(
82
82
const parentBounds = parent . getBoundingClientRect ( ) ;
83
83
const twoScreenHeight = Math . max ( 500 , parentBounds . height * 2 ) ;
84
84
const mdBounds = md . getBoundingClientRect ( ) ;
85
- const isInRange = ( x : number ) =>
86
- x <= parentBounds . bottom + twoScreenHeight &&
87
- x >= parentBounds . top - twoScreenHeight ;
88
- inView . current = isInRange ( mdBounds . top ) || isInRange ( mdBounds . bottom ) ;
85
+ const parentTop = parentBounds . top - twoScreenHeight ;
86
+ const parentBottom = parentBounds . bottom + twoScreenHeight ;
87
+ const isOverlap =
88
+ Math . max ( parentTop , mdBounds . top ) <=
89
+ Math . min ( parentBottom , mdBounds . bottom ) ;
90
+ inView . current = isOverlap ;
89
91
}
90
92
91
93
if ( inView . current && md ) {
You can’t perform that action at this time.
0 commit comments