All files / src/componentsV2/Table/hooks useHandleScroll.tsx

76.92% Statements 10/13
66.66% Branches 6/9
100% Functions 2/2
76.92% Lines 10/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23    27x 874x 8x 8x 8x 8x 8x 7x   8x                 874x    
import { useCallback } from "react";
 
export const useHandleScroll = (noBorder = false) => {
  const onScroll: React.UIEventHandler<HTMLDivElement> = useCallback((e) => {
    const target = e.currentTarget;
    const div = document.getElementById("slide-me");
    const bar = document.getElementById("slide-me2");
    const styleName = noBorder ? "noborder-overlay-enabled" : "overlay-enabled";
    if (div) {
      div.style.transform = `translateY(${-target.scrollTop}px)`;
    }
    Iif (bar) {
      if (target.scrollTop > 1) {
        bar.classList.add(styleName);
      } else {
        bar.classList.remove(styleName);
      }
    }
  }, []);
 
  return { onScroll };
};