Skip to content

Commit fe8e3f2

Browse files
committed
fix: ChatGPTNextWeb#1273 overlap detecting
1 parent 4b9d753 commit fe8e3f2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/components/markdown.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ export function Markdown(
8282
const parentBounds = parent.getBoundingClientRect();
8383
const twoScreenHeight = Math.max(500, parentBounds.height * 2);
8484
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;
8991
}
9092

9193
if (inView.current && md) {

0 commit comments

Comments
 (0)