Gathering detailed insights and metrics for @cutting/use-get-parent-size
Gathering detailed insights and metrics for @cutting/use-get-parent-size
Gathering detailed insights and metrics for @cutting/use-get-parent-size
Gathering detailed insights and metrics for @cutting/use-get-parent-size
npm install @cutting/use-get-parent-size
Typescript
Module System
Node Version
NPM Version
@cutting/use-get-parent-size@2.4.0
Updated on Apr 02, 2025
@cutting/use-shortcuts@4.49.0
Updated on Apr 02, 2025
@cutting/use-mathjax@4.53.0
Updated on Apr 02, 2025
@cutting/component-library@5.45.0
Updated on Apr 02, 2025
@cutting/svg@4.57.0
Updated on Apr 02, 2025
@cutting/react-hook-form-components@0.8.0
Updated on Apr 02, 2025
JavaScript (68.75%)
TypeScript (25.83%)
CSS (3.42%)
HTML (1.3%)
MDX (0.46%)
Shell (0.13%)
Dockerfile (0.09%)
Arc (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
35 Stars
2,515 Commits
2 Forks
2 Watchers
14 Branches
2 Contributors
Updated on May 04, 2025
Latest Version
2.4.0
Package Id
@cutting/use-get-parent-size@2.4.0
Unpacked Size
139.47 kB
Size
41.26 kB
File Count
23
NPM Version
10.8.2
Node Version
18.20.8
Published on
Apr 02, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1pnpm add @cutting/use-get-parent-size 2 3# or 4 5npm install @cutting/use-get-parent-size
A React hook that allows you to use a ResizeObserver to measure an element's size.
1const { width, height } = useParentSize(ref, options);
useParentSize
takes a react ref object and an optional options
object.
Returns the contentRect of the observed element:
1interface DOMRectReadOnly { 2 readonly bottom: number; 3 readonly height: number; 4 readonly left: number; 5 readonly right: number; 6 readonly top: number; 7 readonly width: number; 8 readonly x: number; 9 readonly y: number; 10 toJSON(): any; 11}
1export interface UseParentSizeOptions { 2 debounceDelay: number; 3 initialValues: Partial<ResizeObserverContentRect>; 4 transformFunc?: ( 5 entry: Partial<ResizeObserverContentRect> 6 ) => Partial<ResizeObserverContentRect>; 7 maxDifference?: number; 8 transformFunc?: ({ width, height }: Dimensions) => Dimensions; 9 callback?(entry: ResizeObserverContentRect): void; 10}
debounceDelay
- default 500ms. an optional number
that will throttle the speed at which reize events are raised to the calling code.initialValues
- initially, the ref
will be null
and no width
or height
values can be returned until it is mounted. The initialValues
option can return a specific width
and height
value until the ref
actually references a valid DOM node. e.g. const { width, height } = useParentSize(ref, { width: 100, height: 50})
;Default is an empty DomRect:
1{ 2 bottom: undefined, 3 height: undefined, 4 left: undefined, 5 width: undefined, 6 right: undefined, 7 top: undefined, 8 x: undefined, 9 y: undefined, 10};
transformFunc
optional function to transform the results, e.g. to halve the size of the parent
1transformFunc: ({ width, height }) => ({ 2 width: width / 2, 3 height: height / 2, 4});
Default is identity, (x) => x
maxDifference
(default 10) - useParentSize stores the current DomRect values in memory and if a resize event occurrs, these values are checked against the new DomRect values after the resize. If the difference between the two values is greater than the maxDifference
option then clients are notified.
callback
a function can be provided that is executed on each resize.
1import { useRef } from 'react'; 2import type { UseParentSizeOptions } from '@cutting/use-get-parent-size'; 3 4export function ResponsiveSVG({ 5 children 6}): JSX.Element => { 7 const ref = useRef<HTMLDivElement>(null); 8 const { width, height } = useParentSize(ref, options); 9 const aspect = width / height; 10 11 const adjustedHeight = Math.ceil(width / aspect); 12 13 return ( 14 <div ref={ref}> 15 <svg 16 viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`} 17 > 18 {children} 19 </svg> 20 </div> 21 ); 22};
1const Pipeline = () => { 2 const controller = useVisualizationController(); 3 const containerRef = useRef<HTMLDivElement>(null); 4 5 useParentSize(containerRef, { 6 callback: () => { 7 controller.getGraph().fit(70); 8 }, 9 debounceDelay: 500, 10 });
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 0/16 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More