fix: PC端表头初始化渲染问题
This commit is contained in:
@@ -354,13 +354,19 @@ export default function MobileFundTable({
|
|||||||
const nextStickyTop = getEffectiveStickyTop();
|
const nextStickyTop = getEffectiveStickyTop();
|
||||||
setEffectiveStickyTop((prev) => (prev === nextStickyTop ? prev : nextStickyTop));
|
setEffectiveStickyTop((prev) => (prev === nextStickyTop ? prev : nextStickyTop));
|
||||||
|
|
||||||
const tableRect = tableContainerRef.current?.getBoundingClientRect();
|
const tableEl = tableContainerRef.current;
|
||||||
|
const tableRect = tableEl?.getBoundingClientRect();
|
||||||
if (!tableRect) {
|
if (!tableRect) {
|
||||||
setShowPortalHeader(window.scrollY >= nextStickyTop);
|
setShowPortalHeader(window.scrollY >= nextStickyTop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShowPortalHeader(tableRect.top <= nextStickyTop);
|
const headerEl = tableEl?.querySelector('.table-header-row');
|
||||||
|
const headerHeight = headerEl?.getBoundingClientRect?.().height ?? 0;
|
||||||
|
const hasPassedHeader = (tableRect.top + headerHeight) <= nextStickyTop;
|
||||||
|
const hasTableInView = tableRect.bottom > nextStickyTop;
|
||||||
|
|
||||||
|
setShowPortalHeader(hasPassedHeader && hasTableInView);
|
||||||
};
|
};
|
||||||
|
|
||||||
const throttledVerticalUpdate = throttle(updateVerticalState, 1000/60, { leading: true, trailing: true });
|
const throttledVerticalUpdate = throttle(updateVerticalState, 1000/60, { leading: true, trailing: true });
|
||||||
|
|||||||
@@ -412,7 +412,12 @@ export default function PcFundTable({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShowPortalHeader(rect.top <= nextStickyTop);
|
const headerEl = tableEl?.querySelector('.table-header-row');
|
||||||
|
const headerHeight = headerEl?.getBoundingClientRect?.().height ?? 0;
|
||||||
|
const hasPassedHeader = (rect.top + headerHeight) <= nextStickyTop;
|
||||||
|
const hasTableInView = rect.bottom > nextStickyTop;
|
||||||
|
|
||||||
|
setShowPortalHeader(hasPassedHeader && hasTableInView);
|
||||||
|
|
||||||
setPortalHorizontal((prev) => {
|
setPortalHorizontal((prev) => {
|
||||||
const next = {
|
const next = {
|
||||||
|
|||||||
Reference in New Issue
Block a user