Socket
Socket
Sign inDemoInstall

@reach/rect

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/rect - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

LICENSE

17

dist/index.d.ts

@@ -11,3 +11,2 @@ /**

import React from "react";
import { Rect as TRect, PartialRect } from "@reach/observe-rect";
/**

@@ -43,3 +42,3 @@ * Rect

*/
onChange?: (rect: PartialRect) => void;
onChange?: (rect: PRect) => void;
/**

@@ -56,3 +55,3 @@ * A function that calls back to you with a `ref` to place on an element and

children(args: {
rect: TRect | null;
rect: PRect | null;
ref: React.Ref<any>;

@@ -68,4 +67,12 @@ }): JSX.Element;

*/
export declare function useRect<T extends HTMLElement = HTMLElement>(nodeRef: React.RefObject<T>, observe?: boolean, onChange?: (rect: Partial<TRect>) => void): Pick<DOMRect, "width" | "height" | "top" | "right" | "bottom" | "left"> | null;
export declare function useRect<T extends HTMLElement = HTMLElement>(nodeRef: React.RefObject<T>, observe?: boolean, onChange?: (rect: DOMRect) => void): null | DOMRect;
export default Rect;
export { TRect, PartialRect };
export declare type PartialRect = Partial<PRect>;
export declare type PRect = Partial<DOMRect> & {
readonly bottom: number;
readonly height: number;
readonly left: number;
readonly right: number;
readonly top: number;
readonly width: number;
};

@@ -63,2 +63,4 @@ 'use strict';

var initialRectSet = react.useRef(false);
var _a = react.useState(null),

@@ -86,2 +88,7 @@ rect = _a[0],

if (!initialRectSet.current) {
initialRectSet.current = true;
setRect(nodeRef.current.getBoundingClientRect());
}
observe && observerRef.current.observe();

@@ -88,0 +95,0 @@ return cleanup; // eslint-disable-next-line react-hooks/exhaustive-deps

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("prop-types");var r,t=(r=require("@reach/observe-rect"))&&"object"==typeof r&&"default"in r?r.default:r,u=function(r){var t=r.onChange,u=r.observe,c=void 0===u||u,o=r.children,s=e.useRef(null);return o({ref:s,rect:n(s,c,t)})};function n(r,u,n){void 0===u&&(u=!0);var c=e.useState(null),o=c[0],s=c[1],a=e.useRef(null);return e.useLayoutEffect((function(){var e=function(){a.current&&a.current.unobserve()};return r.current?(!a.current&&r.current&&(a.current=t(r.current,(function(e){n&&n(e),s(e)}))),u&&a.current.observe(),e):(console.warn("You need to place the ref"),e)}),[u,n]),o}u.displayName="Rect",exports.Rect=u,exports.default=u,exports.useRect=n;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("prop-types");var r,t=(r=require("@reach/observe-rect"))&&"object"==typeof r&&"default"in r?r.default:r,u=function(r){var t=r.onChange,u=r.observe,c=void 0===u||u,o=r.children,s=e.useRef(null);return o({ref:s,rect:n(s,c,t)})};function n(r,u,n){void 0===u&&(u=!0);var c=e.useRef(!1),o=e.useState(null),s=o[0],a=o[1],f=e.useRef(null);return e.useLayoutEffect((function(){var e=function(){f.current&&f.current.unobserve()};return r.current?(!f.current&&r.current&&(f.current=t(r.current,(function(e){n&&n(e),a(e)}))),c.current||(c.current=!0,a(r.current.getBoundingClientRect())),u&&f.current.observe(),e):(console.warn("You need to place the ref"),e)}),[u,n]),s}u.displayName="Rect",exports.Rect=u,exports.default=u,exports.useRect=n;
//# sourceMappingURL=rect.cjs.production.min.js.map

@@ -57,2 +57,4 @@ import { useRef, useState, useLayoutEffect } from 'react';

var initialRectSet = useRef(false);
var _a = useState(null),

@@ -80,2 +82,7 @@ rect = _a[0],

if (!initialRectSet.current) {
initialRectSet.current = true;
setRect(nodeRef.current.getBoundingClientRect());
}
observe && observerRef.current.observe();

@@ -82,0 +89,0 @@ return cleanup; // eslint-disable-next-line react-hooks/exhaustive-deps

{
"name": "@reach/rect",
"version": "0.7.1",
"version": "0.7.2",
"description": "Measure React elements position in the DOM",
"author": "React Training <hello@reacttraining.com>",
"license": "MIT",
"repository": {

@@ -10,14 +12,9 @@ "type": "git",

},
"main": "dist/index.js",
"umd:main": "dist/rect.umd.production.js",
"module": "dist/rect.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "cross-env NODE_ENV=production tsdx build --format=cjs,esm,umd"
"build": "yarn clean && cross-env NODE_ENV=production tsdx build --format=cjs,esm --tsconfig tsconfig.build.json",
"clean": "rm -rf ./dist",
"compile": "cross-env NODE_ENV=production tsdx build --format=cjs,esm --tsconfig tsconfig.build.json"
},
"dependencies": {
"@reach/observe-rect": "^1.0.4",
"@reach/observe-rect": "^1.0.5",
"prop-types": "^15.7.2"

@@ -29,4 +26,9 @@ },

},
"author": "React Training <hello@reacttraining.com>",
"license": "MIT"
"main": "dist/index.js",
"module": "dist/rect.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"gitHead": "96cf6c191cca0f2cbcb7ff578f15e289efeda1e2"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc