UNPKG

@react-awesome/use-breakpoint

Version:

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

12 lines (11 loc) 535 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const between = (BREAKPOINTS, containerEl, direction = "horizontal") => (minBreakpoint, maxBreakpoint) => { if (!containerEl) return false; const min = BREAKPOINTS[minBreakpoint]; const max = BREAKPOINTS[maxBreakpoint]; const dimension = direction === "horizontal" ? "width" : "height"; return containerEl.getBoundingClientRect()[dimension] > min && containerEl.getBoundingClientRect()[dimension] < max; }; exports.between = between;