forked from XiaoMo/ChatGPT-Next-Web
fix: #1273 overlap detecting
This commit is contained in:
parent
4b9d753254
commit
fe8e3f2bcf
@ -82,10 +82,12 @@ export function Markdown(
|
|||||||
const parentBounds = parent.getBoundingClientRect();
|
const parentBounds = parent.getBoundingClientRect();
|
||||||
const twoScreenHeight = Math.max(500, parentBounds.height * 2);
|
const twoScreenHeight = Math.max(500, parentBounds.height * 2);
|
||||||
const mdBounds = md.getBoundingClientRect();
|
const mdBounds = md.getBoundingClientRect();
|
||||||
const isInRange = (x: number) =>
|
const parentTop = parentBounds.top - twoScreenHeight;
|
||||||
x <= parentBounds.bottom + twoScreenHeight &&
|
const parentBottom = parentBounds.bottom + twoScreenHeight;
|
||||||
x >= parentBounds.top - twoScreenHeight;
|
const isOverlap =
|
||||||
inView.current = isInRange(mdBounds.top) || isInRange(mdBounds.bottom);
|
Math.max(parentTop, mdBounds.top) <=
|
||||||
|
Math.min(parentBottom, mdBounds.bottom);
|
||||||
|
inView.current = isOverlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inView.current && md) {
|
if (inView.current && md) {
|
||||||
|
Loading…
Reference in New Issue
Block a user