UNPKG

@react-awesome/use-breakpoint

Version:

useBreakpoint triggers callback when a container's size is equal to one specific breakpoint.

11 lines (10 loc) 328 B
const smaller = (BREAKPOINTS, containerEl, direction = "horizontal") => (breakpoint) => { if (!containerEl) return false; const value = BREAKPOINTS[breakpoint]; const dimension = direction === "horizontal" ? "width" : "height"; return containerEl.getBoundingClientRect()[dimension] < value; }; export { smaller };