mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
hide sticky table group after scrolling past
This commit is contained in:
+15
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import { useInView } from 'motion/react';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { useWindowSettings } from '/@/renderer/store/settings.store';
|
import { useWindowSettings } from '/@/renderer/store/settings.store';
|
||||||
@@ -32,6 +33,15 @@ export const useStickyTableGroupRows = ({
|
|||||||
const { windowBarStyle } = useWindowSettings();
|
const { windowBarStyle } = useWindowSettings();
|
||||||
const [stickyGroupIndex, setStickyGroupIndex] = useState<null | number>(null);
|
const [stickyGroupIndex, setStickyGroupIndex] = useState<null | number>(null);
|
||||||
|
|
||||||
|
const topMargin =
|
||||||
|
windowBarStyle === Platform.WINDOWS || windowBarStyle === Platform.MACOS
|
||||||
|
? '-130px'
|
||||||
|
: '-100px';
|
||||||
|
|
||||||
|
const isTableInView = useInView(containerRef, {
|
||||||
|
margin: `${topMargin} 0px 0px 0px`,
|
||||||
|
});
|
||||||
|
|
||||||
const stickyTop = useMemo(() => {
|
const stickyTop = useMemo(() => {
|
||||||
// If sticky header is showing, position group row below it with 1px offset to avoid conflict
|
// If sticky header is showing, position group row below it with 1px offset to avoid conflict
|
||||||
// Otherwise, use the base sticky position
|
// Otherwise, use the base sticky position
|
||||||
@@ -169,8 +179,12 @@ export const useStickyTableGroupRows = ({
|
|||||||
stickyTop,
|
stickyTop,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const shouldShowStickyGroupRow = useMemo(() => {
|
||||||
|
return enabled && stickyGroupIndex !== null && isTableInView;
|
||||||
|
}, [enabled, stickyGroupIndex, isTableInView]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
shouldShowStickyGroupRow: stickyGroupIndex !== null,
|
shouldShowStickyGroupRow,
|
||||||
stickyGroupIndex,
|
stickyGroupIndex,
|
||||||
stickyTop,
|
stickyTop,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user