Fine-tune rootMargin to catch intersections on small screen

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2021-03-12 15:25:23 +03:00
1 parent 6fd20bd169
commit 5bf3d3a188
2 files changed
+2 -2

No files matched your search

@@ -32,7 +32,7 @@ export class Preferences extends React.Component {
render() { render() {
const { preferences } = userStore; const { preferences } = userStore;
const header = <h2>Preferences</h2>; const header = <h2>Preferences</h2>;
const rootMargin = "80px 0px -85%"; // Cut header size from the top and 85% from the bottom of viewport const rootMargin = "80px 0px -80%";
let defaultShell = process.env.SHELL || process.env.PTYSHELL; let defaultShell = process.env.SHELL || process.env.PTYSHELL;
if (!defaultShell) { if (!defaultShell) {
@@ -8,7 +8,7 @@ interface Props extends React.DOMAttributes<HTMLElement> {
rootMargin?: string // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#creating_an_intersection_observer rootMargin?: string // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#creating_an_intersection_observer
} }
export const ScrollSpy = observer(({ render, rootMargin = "0px 0px -85%" }: Props) => { export const ScrollSpy = observer(({ render, rootMargin = "0px 0px -80%" }: Props) => {
const parent = useRef<HTMLDivElement>(); const parent = useRef<HTMLDivElement>();
const sections = useRef<NodeListOf<HTMLElement>>(); const sections = useRef<NodeListOf<HTMLElement>>();
const [tree, setTree] = useState<NavigationTree[]>([]); const [tree, setTree] = useState<NavigationTree[]>([]);