Comparing version 1.10.0 to 1.10.1
@@ -1,1 +0,1 @@ | ||
export declare function useMinWindowWidth(minWidth: number, initialWidth?: number): boolean; | ||
export declare function useMinWindowWidth(minWidth: number): boolean | undefined; |
@@ -18,18 +18,12 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_debounce_1 = __importDefault(require("lodash.debounce")); | ||
var react_1 = require("react"); | ||
var isBrowser_1 = require("../utils/isBrowser"); | ||
var useIsMounted_1 = require("./useIsMounted"); | ||
var useRafState_1 = require("./useRafState"); | ||
function useMinWindowWidth(minWidth, initialWidth) { | ||
if (initialWidth === void 0) { initialWidth = 1200; } | ||
var _a = __read(useRafState_1.useRafState((isBrowser_1.isBrowser ? window.innerWidth : initialWidth) >= minWidth), 2), state = _a[0], setState = _a[1]; | ||
var isMounted = useIsMounted_1.useIsMounted(); | ||
function useMinWindowWidth(minWidth) { | ||
var _a = __read(useRafState_1.useRafState(undefined), 2), state = _a[0], setState = _a[1]; | ||
react_1.useEffect(function () { | ||
if (isBrowser_1.isBrowser) { | ||
var handler_1 = lodash_debounce_1.default(function () { return setState(window.innerWidth >= minWidth); }, 100); | ||
var handler_1 = function () { return setState(window.innerWidth >= minWidth); }; | ||
handler_1(); | ||
window.addEventListener("resize", handler_1); | ||
@@ -40,6 +34,6 @@ return function () { | ||
} | ||
}, []); | ||
return isMounted ? state : false; | ||
}, [minWidth, setState]); | ||
return state; | ||
} | ||
exports.useMinWindowWidth = useMinWindowWidth; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlTWluV2luZG93V2lkdGguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9va3MvdXNlTWluV2luZG93V2lkdGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs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ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0JBQWtDO0FBQ2xDLGdEQUErQztBQUMvQyw2Q0FBNEM7QUFFNUMsU0FBZ0IsaUJBQWlCLENBQUMsUUFBZ0I7SUFDeEMsSUFBQSxvREFBK0QsRUFBOUQsYUFBSyxFQUFFLGdCQUF1RCxDQUFDO0lBRXRFLGlCQUFTLENBQUM7UUFDTixJQUFJLHFCQUFTLEVBQUU7WUFDWCxJQUFNLFNBQU8sR0FBRyxjQUFNLE9BQUEsUUFBUSxDQUFDLE1BQU0sQ0FBQyxVQUFVLElBQUksUUFBUSxDQUFDLEVBQXZDLENBQXVDLENBQUM7WUFDOUQsU0FBTyxFQUFFLENBQUM7WUFFVixNQUFNLENBQUMsZ0JBQWdCLENBQUMsUUFBUSxFQUFFLFNBQU8sQ0FBQyxDQUFDO1lBQzNDLE9BQU87Z0JBQ0gsTUFBTSxDQUFDLG1CQUFtQixDQUFDLFFBQVEsRUFBRSxTQUFPLENBQUMsQ0FBQztZQUNsRCxDQUFDLENBQUM7U0FDTDtJQUNMLENBQUMsRUFBRSxDQUFDLFFBQVEsRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUFDO0lBRXpCLE9BQU8sS0FBSyxDQUFDO0FBQ2pCLENBQUM7QUFoQkQsOENBZ0JDIn0= |
export declare function useWindowScroll(): { | ||
x: number; | ||
y: number; | ||
}; | ||
} | undefined; |
@@ -23,10 +23,7 @@ "use strict"; | ||
function useWindowScroll() { | ||
var _a = __read(useRafState_1.useRafState({ | ||
x: isBrowser_1.isBrowser ? window.pageXOffset : 0, | ||
y: isBrowser_1.isBrowser ? window.pageYOffset : 0, | ||
}), 2), state = _a[0], setState = _a[1]; | ||
var _a = __read(useRafState_1.useRafState(undefined), 2), state = _a[0], setState = _a[1]; | ||
react_1.useEffect(function () { | ||
if (isBrowser_1.isBrowser) { | ||
var handler_1 = function () { | ||
setState({ | ||
return setState({ | ||
x: window.pageXOffset, | ||
@@ -36,2 +33,3 @@ y: window.pageYOffset, | ||
}; | ||
handler_1(); | ||
window.addEventListener("scroll", handler_1, { | ||
@@ -45,6 +43,6 @@ capture: false, | ||
} | ||
}, []); | ||
}, [setState]); | ||
return state; | ||
} | ||
exports.useWindowScroll = useWindowScroll; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlV2luZG93U2Nyb2xsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hvb2tzL3VzZVdpbmRvd1Njcm9sbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrQkFBa0M7QUFDbEMsZ0RBQStDO0FBQy9DLDZDQUE0QztBQUU1QyxTQUFnQixlQUFlO0lBQ3JCLElBQUE7OztVQUdKLEVBSEssYUFBSyxFQUFFLGdCQUdaLENBQUM7SUFFSCxpQkFBUyxDQUFDO1FBQ04sSUFBSSxxQkFBUyxFQUFFO1lBQ1gsSUFBTSxTQUFPLEdBQUc7Z0JBQ1osUUFBUSxDQUFDO29CQUNMLENBQUMsRUFBRSxNQUFNLENBQUMsV0FBVztvQkFDckIsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxXQUFXO2lCQUN4QixDQUFDLENBQUM7WUFDUCxDQUFDLENBQUM7WUFFRixNQUFNLENBQUMsZ0JBQWdCLENBQUMsUUFBUSxFQUFFLFNBQU8sRUFBRTtnQkFDdkMsT0FBTyxFQUFFLEtBQUs7Z0JBQ2QsT0FBTyxFQUFFLElBQUk7YUFDaEIsQ0FBQyxDQUFDO1lBQ0gsT0FBTztnQkFDSCxNQUFNLENBQUMsbUJBQW1CLENBQUMsUUFBUSxFQUFFLFNBQU8sQ0FBQyxDQUFDO1lBQ2xELENBQUMsQ0FBQztTQUNMO0lBQ0wsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDO0lBRVAsT0FBTyxLQUFLLENB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@@ | ||
export declare function useWindowSize(initialWidth?: number, initialHeight?: number): { | ||
export declare function useWindowSize(): { | ||
width: number; | ||
height: number; | ||
}; | ||
} | undefined; |
@@ -22,13 +22,8 @@ "use strict"; | ||
var useRafState_1 = require("./useRafState"); | ||
function useWindowSize(initialWidth, initialHeight) { | ||
if (initialWidth === void 0) { initialWidth = Infinity; } | ||
if (initialHeight === void 0) { initialHeight = Infinity; } | ||
var _a = __read(useRafState_1.useRafState({ | ||
width: isBrowser_1.isBrowser ? window.innerWidth : initialWidth, | ||
height: isBrowser_1.isBrowser ? window.innerHeight : initialHeight, | ||
}), 2), state = _a[0], setState = _a[1]; | ||
function useWindowSize() { | ||
var _a = __read(useRafState_1.useRafState(undefined), 2), state = _a[0], setState = _a[1]; | ||
react_1.useEffect(function () { | ||
if (isBrowser_1.isBrowser) { | ||
var handler_1 = function () { | ||
setState({ | ||
return setState({ | ||
width: window.innerWidth, | ||
@@ -38,2 +33,3 @@ height: window.innerHeight, | ||
}; | ||
handler_1(); | ||
window.addEventListener("resize", handler_1); | ||
@@ -44,6 +40,6 @@ return function () { | ||
} | ||
}, []); | ||
}, [setState]); | ||
return state; | ||
} | ||
exports.useWindowSize = useWindowSize; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlV2luZG93U2l6ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ob29rcy91c2VXaW5kb3dTaXplLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLCtCQUFrQztBQUNsQyxnREFBK0M7QUFDL0MsNkNBQTRDO0FBRTVDLFNBQWdCLGFBQWEsQ0FBQyxZQUF1QixFQUFFLGFBQXdCO0lBQWpELDZCQUFBLEVBQUEsdUJBQXVCO0lBQUUsOEJBQUEsRUFBQSx3QkFBd0I7SUFDckUsSUFBQTs7O1VBR0osRUFISy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CLE1BQU0sRUFBRSxNQUFNLENBQUMsV0FBVztpQkFDN0IsQ0FBQztZQUhGLENBR0UsQ0FBQztZQUNQLFNBQU8sRUFBRSxDQUFDO1lBRVYsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFFBQVEsRUFBRSxTQUFPLENBQUMsQ0FBQztZQUMzQyxPQUFPO2dCQUNILE1BQU0sQ0FBQyxtQkFBbUIsQ0FBQyxRQUFRLEVBQUUsU0FBTyxDQUFDLENBQUM7WUFDbEQsQ0FBQyxDQUFDO1NBQ0w7SUFDTCxDQUFDLEVBQUUsQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDO0lBRWYsT0FBTyxLQUFLLENBQUM7QUFDakIsQ0FBQztBQXBCRCxzQ0FvQkMifQ== |
{ | ||
"name": "@uxf/core", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "UXF Core", | ||
@@ -5,0 +5,0 @@ "author": "Petr Vejvoda <vejvoda@uxf.cz>", |
@@ -74,3 +74,5 @@ # UXF Core | ||
const isDesktop = useMinWindowWidth(992 /* desired min window width */, 1280 /* initial window width (optional) */); | ||
const isDesktop = useMinWindowWidth(1200); | ||
const example = isDesktop ? "desktop" : "tablet"; | ||
``` | ||
@@ -104,3 +106,5 @@ | ||
const { x, y } = useWindowScroll(); | ||
const windowScroll = useWindowScroll(); | ||
const example = windowScroll && windowScroll.y > 100 ? "scroled" : "on top"; | ||
``` | ||
@@ -110,3 +114,5 @@ ```tsx | ||
const { width, height } = useWindowSize(1280 /* initial window width (optional) */, 800 /* initial window height (optional) */); | ||
const windowSize = useWindowSize(); | ||
const example = windowSize && windowSize.width > 1200 ? "desktop" : "tablet"; | ||
``` | ||
@@ -113,0 +119,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164
71671
819