mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Updated sticky header logic.
This commit is contained in:
parent
8532c673fe
commit
f3e1f18e1b
7 changed files with 41 additions and 76 deletions
|
|
@ -1,32 +0,0 @@
|
|||
import { useMeasure } from 'react-basics';
|
||||
import classNames from 'classnames';
|
||||
import useSticky from 'hooks/useSticky';
|
||||
|
||||
export default function StickyHeader({
|
||||
className,
|
||||
stickyClassName,
|
||||
stickyStyle,
|
||||
enabled = true,
|
||||
scrollElement,
|
||||
children,
|
||||
}) {
|
||||
const { ref: scrollRef, isSticky } = useSticky({ scrollElement });
|
||||
const { ref: measureRef, dimensions } = useMeasure();
|
||||
const active = enabled && isSticky;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={measureRef}
|
||||
data-sticky={active}
|
||||
style={active ? { height: dimensions.height } : null}
|
||||
>
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className={classNames(className, { [stickyClassName]: active })}
|
||||
style={active ? { ...stickyStyle, width: dimensions.width } : null}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue