package.react-utils.useBreakpoints.utils.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
export var subscribe = function subscribe(listener) {
window.addEventListener("resize", listener);
return function () {
return window.removeEventListener("resize", listener);
};
};
export var getCurrentSize = function getCurrentSize(window, breakpointOverrides) {
var innerWidth = window.innerWidth;
var sizes = _objectSpread({
mobile: innerWidth < 768,
tablet: innerWidth >= 768 && innerWidth < 1024,
desktop: innerWidth >= 1024 && innerWidth < 1280,
largeDesktop: innerWidth >= 1280
}, breakpointOverrides === null || breakpointOverrides === void 0 ? void 0 : breakpointOverrides(window));
var size = Object.keys(sizes).find(function (breakpoint) {
return sizes[breakpoint];
}) || "";
return size;
};
//# sourceMappingURL=utils.js.map