Ignore:
Timestamp:
01/21/25 03:08:24 (3 months ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

Location:
imaps-frontend/node_modules/react-use/esm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/react-use/esm/useWindowSize.d.ts

    r0c6b92a r79a0317  
    1 declare const useWindowSize: (initialWidth?: number, initialHeight?: number) => {
     1interface Options {
     2    initialWidth?: number;
     3    initialHeight?: number;
     4    onChange?: (width: number, height: number) => void;
     5}
     6declare const useWindowSize: ({ initialWidth, initialHeight, onChange, }?: Options) => {
    27    width: number;
    38    height: number;
  • imaps-frontend/node_modules/react-use/esm/useWindowSize.js

    r0c6b92a r79a0317  
    22import useRafState from './useRafState';
    33import { isBrowser, off, on } from './misc/util';
    4 var useWindowSize = function (initialWidth, initialHeight) {
    5     if (initialWidth === void 0) { initialWidth = Infinity; }
    6     if (initialHeight === void 0) { initialHeight = Infinity; }
    7     var _a = useRafState({
     4var useWindowSize = function (_a) {
     5    var _b = _a === void 0 ? {} : _a, _c = _b.initialWidth, initialWidth = _c === void 0 ? Infinity : _c, _d = _b.initialHeight, initialHeight = _d === void 0 ? Infinity : _d, onChange = _b.onChange;
     6    // Use the useRafState hook to maintain the current window size (width and height)
     7    var _e = useRafState({
    88        width: isBrowser ? window.innerWidth : initialWidth,
    99        height: isBrowser ? window.innerHeight : initialHeight,
    10     }), state = _a[0], setState = _a[1];
     10    }), state = _e[0], setState = _e[1];
    1111    useEffect(function () {
     12        // Only run the effect on the browser (to avoid issues with SSR)
    1213        if (isBrowser) {
    1314            var handler_1 = function () {
     15                var width = window.innerWidth;
     16                var height = window.innerHeight;
     17                // Update the state with the new window size
    1418                setState({
    15                     width: window.innerWidth,
    16                     height: window.innerHeight,
     19                    width: width,
     20                    height: height,
    1721                });
     22                // If an onChange callback is provided, call it with the new dimensions
     23                if (onChange)
     24                    onChange(width, height);
    1825            };
     26            // Add event listener for the resize event
    1927            on(window, 'resize', handler_1);
     28            // Cleanup function to remove the event listener when the component is unmounted (it's for performance optimization)
    2029            return function () {
    2130                off(window, 'resize', handler_1);
     
    2332        }
    2433    }, []);
     34    // Return the current window size (width and height)
    2535    return state;
    2636};
Note: See TracChangeset for help on using the changeset viewer.