function findHighId()

in src/hooks/useScrollHash.ts [5:24]


function findHighId(
  scrollPosition: number,
  scrollIdSelect: NodeListOf<HTMLElement>
) {
  let smallN = Number.MAX_SAFE_INTEGER;
  let id;
  scrollIdSelect.forEach((item) => {
    if (!item.dataset.id) return;
    const targetPosition = item.offsetTop;

    if (!targetPosition) return;
    const pod = targetPosition - scrollPosition;
    // select small pod
    if (pod > 0 && pod < smallN) {
      smallN = pod;
      id = item.dataset.id;
    }
  });
  return id;
}