UNPKG

@react-awesome/use-breakpoint

Version:

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

11 lines (10 loc) 343 B
const greaterOrEqual = (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 { greaterOrEqual };