react-use-measure
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"dist/web.js": { | ||
"bundled": 5070, | ||
"minified": 2602, | ||
"gzipped": 1058, | ||
"treeshaked": { | ||
"rollup": { | ||
"code": 2340, | ||
"import_statements": 109 | ||
}, | ||
"webpack": { | ||
"code": 3603 | ||
} | ||
} | ||
}, | ||
"dist/web.cjs.js": { | ||
"bundled": 5777, | ||
"minified": 2805, | ||
"gzipped": 1108 | ||
}, | ||
"web.js": { | ||
@@ -22,0 +3,0 @@ "bundled": 5011, |
{ | ||
"name": "react-use-measure", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "measure view bounds", | ||
@@ -5,0 +5,0 @@ "main": "./dist/web.cjs.js", |
@@ -55,3 +55,3 @@ <p align="center"> | ||
options: Options = { debounce: 0, scroll: false } | ||
): [React.MutableRefObject<HTMLElement>, RectReadOnly] | ||
): [React.MutableRefObject<HTMLElement | SVGElement>, RectReadOnly] | ||
``` | ||
@@ -58,0 +58,0 @@ |
@@ -25,7 +25,9 @@ import { useEffect, useState, useRef, useMemo } from 'react' | ||
type Result = [(element: HTMLElement | null) => void, RectReadOnly, () => void] | ||
type HTMLOrSVGElement = HTMLElement | SVGElement | ||
type Result = [(element: HTMLOrSVGElement | null) => void, RectReadOnly, () => void] | ||
type State = { | ||
element: HTMLElement | null | ||
scrollContainers: HTMLElement[] | null | ||
element: HTMLOrSVGElement | null | ||
scrollContainers: HTMLOrSVGElement[] | null | ||
resizeObserver: ResizeObserver | null | ||
@@ -120,3 +122,3 @@ lastBounds: RectReadOnly | ||
// the ref we expose to the user | ||
const ref = (node: HTMLElement | null) => { | ||
const ref = (node: HTMLOrSVGElement | null) => { | ||
if (!node || node === state.current.element) return | ||
@@ -163,4 +165,4 @@ removeListeners() | ||
// Returns a list of scroll offsets | ||
function findScrollContainers(element: HTMLElement | null): HTMLElement[] { | ||
const result: HTMLElement[] = [] | ||
function findScrollContainers(element: HTMLOrSVGElement | null): HTMLOrSVGElement[] { | ||
const result: HTMLOrSVGElement[] = [] | ||
if (!element || element === document.body) return result | ||
@@ -167,0 +169,0 @@ const { overflow, overflowX, overflowY } = window.getComputedStyle(element) |
@@ -20,3 +20,4 @@ declare type ResizeObserverCallback = (entries: any[], observer: ResizeObserver) => void | ||
} | ||
declare type Result = [(element: HTMLElement | null) => void, RectReadOnly, () => void] | ||
declare type HTMLOrSVGElement = HTMLElement | SVGElement | ||
declare type Result = [(element: HTMLOrSVGElement | null) => void, RectReadOnly, () => void] | ||
export declare type Options = { | ||
@@ -23,0 +24,0 @@ debounce?: |
546712
985