Initial project import
This commit is contained in:
21
node_modules/react-use-measure/LICENSE
generated
vendored
Normal file
21
node_modules/react-use-measure/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2025 Poimandres
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
75
node_modules/react-use-measure/README.md
generated
vendored
Normal file
75
node_modules/react-use-measure/README.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<p align="center">
|
||||
<img height="400" src="https://i.imgur.com/eMYYMla.jpg" />
|
||||
</p>
|
||||
|
||||
yarn add react-use-measure
|
||||
|
||||
This small tool will measure the boundaries (for instance width, height, top, left) of a view you reference. It is reactive and responds to changes in size, window-scroll and nested-area-scroll.
|
||||
|
||||
### Why do we need this hook?
|
||||
|
||||
Because there is [no simple way](https://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element) to just get relative view coordinates. Yes, there is getBoundingClientRect, but it does not work when your content sits inside scroll areas whose offsets are simply neglected (as well as page scroll). Worse, mouse coordinates are relative to the viewport (the visible rect that contains the page). There is no easy way, for instance, to know that the mouse hovers over the upper/left corner of an element. This hook solves it for you.
|
||||
|
||||
You can try a live demo here: https://codesandbox.io/s/musing-kare-4fblz
|
||||
|
||||
# Usage
|
||||
|
||||
```jsx
|
||||
import useMeasure from 'react-use-measure'
|
||||
|
||||
function App() {
|
||||
const [ref, bounds] = useMeasure()
|
||||
|
||||
// consider that knowing bounds is only possible *after* the view renders
|
||||
// so you'll get zero values on the first run and be informed later
|
||||
|
||||
return <div ref={ref} />
|
||||
}
|
||||
```
|
||||
|
||||
# Api
|
||||
|
||||
```jsx
|
||||
interface RectReadOnly {
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
readonly width: number
|
||||
readonly height: number
|
||||
readonly top: number
|
||||
readonly right: number
|
||||
readonly bottom: number
|
||||
readonly left: number
|
||||
}
|
||||
|
||||
type Options = {
|
||||
// Debounce events in milliseconds
|
||||
debounce?: number | { scroll: number; resize: number }
|
||||
// React to nested scroll changes, don't use this if you know your view is static
|
||||
scroll?: boolean
|
||||
// You can optionally inject a resize-observer polyfill
|
||||
polyfill?: { new (cb: ResizeObserverCallback): ResizeObserver }
|
||||
// Measure size using offsetHeight and offsetWidth to ignore parent scale transforms
|
||||
offsetSize?: boolean
|
||||
}
|
||||
|
||||
useMeasure(
|
||||
options: Options = { debounce: 0, scroll: false }
|
||||
): [React.MutableRefObject<HTMLElement | SVGElement>, RectReadOnly]
|
||||
```
|
||||
|
||||
# ⚠️ Notes
|
||||
|
||||
### Resize-observer polyfills
|
||||
|
||||
This lib relies on resize-observers. If you need a polyfill you can either polute the `window` object or inject it cleanly using the config options. We recommend [@juggle/resize-observer](https://github.com/juggle/resize-observer).
|
||||
|
||||
```jsx
|
||||
import { ResizeObserver } from '@juggle/resize-observer'
|
||||
|
||||
function App() {
|
||||
const [ref, bounds] = useMeasure({ polyfill: ResizeObserver })
|
||||
```
|
||||
|
||||
### Multiple refs
|
||||
|
||||
useMeasure currently returns its own ref. We do this because we are using functional refs for unmount tracking. If you need to have a ref of your own on the same element, use [react-merge-refs](https://github.com/smooth-code/react-merge-refs).
|
||||
2
node_modules/react-use-measure/dist/index.cjs
generated
vendored
Normal file
2
node_modules/react-use-measure/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";const i=require("react");function b(n,t){let o;return(...s)=>{window.clearTimeout(o),o=window.setTimeout(()=>n(...s),t)}}function S({debounce:n,scroll:t,polyfill:o,offsetSize:s}={debounce:0,scroll:!1,offsetSize:!1}){const a=o||(typeof window=="undefined"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[l,h]=i.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),e=i.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:l,orientationHandler:null}),d=n?typeof n=="number"?n:n.scroll:null,f=n?typeof n=="number"?n:n.resize:null,w=i.useRef(!1);i.useEffect(()=>(w.current=!0,()=>void(w.current=!1)));const[p,m,c]=i.useMemo(()=>{const r=()=>{if(!e.current.element)return;const{left:L,top:y,width:C,height:H,bottom:O,right:x,x:R,y:B}=e.current.element.getBoundingClientRect(),u={left:L,top:y,width:C,height:H,bottom:O,right:x,x:R,y:B};e.current.element instanceof HTMLElement&&s&&(u.height=e.current.element.offsetHeight,u.width=e.current.element.offsetWidth),Object.freeze(u),w.current&&!q(e.current.lastBounds,u)&&h(e.current.lastBounds=u)};return[r,f?b(r,f):r,d?b(r,d):r]},[h,s,d,f]);function v(){e.current.scrollContainers&&(e.current.scrollContainers.forEach(r=>r.removeEventListener("scroll",c,!0)),e.current.scrollContainers=null),e.current.resizeObserver&&(e.current.resizeObserver.disconnect(),e.current.resizeObserver=null),e.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",e.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",e.current.orientationHandler))}function E(){e.current.element&&(e.current.resizeObserver=new a(c),e.current.resizeObserver.observe(e.current.element),t&&e.current.scrollContainers&&e.current.scrollContainers.forEach(r=>r.addEventListener("scroll",c,{capture:!0,passive:!0})),e.current.orientationHandler=()=>{c()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",e.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",e.current.orientationHandler))}const z=r=>{!r||r===e.current.element||(v(),e.current.element=r,e.current.scrollContainers=g(r),E())};return D(c,!!t),T(m),i.useEffect(()=>{v(),E()},[t,c,m]),i.useEffect(()=>v,[]),[z,l,p]}function T(n){i.useEffect(()=>{const t=n;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[n])}function D(n,t){i.useEffect(()=>{if(t){const o=n;return window.addEventListener("scroll",o,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",o,!0)}},[n,t])}function g(n){const t=[];if(!n||n===document.body)return t;const{overflow:o,overflowX:s,overflowY:a}=window.getComputedStyle(n);return[o,s,a].some(l=>l==="auto"||l==="scroll")&&t.push(n),[...t,...g(n.parentElement)]}const M=["x","y","top","bottom","left","right","width","height"],q=(n,t)=>M.every(o=>n[o]===t[o]);module.exports=S;
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
node_modules/react-use-measure/dist/index.cjs.map
generated
vendored
Normal file
1
node_modules/react-use-measure/dist/index.cjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":null,"names":["createDebounce","callback","ms","timeoutId","args","useMeasure","debounce","scroll","polyfill","offsetSize","ResizeObserver","bounds","set","useState","state","useRef","scrollDebounce","resizeDebounce","mounted","useEffect","forceRefresh","resizeChange","scrollChange","useMemo","left","top","width","height","bottom","right","x","y","size","areBoundsEqual","removeListeners","element","addListeners","scrollContainer","ref","node","findScrollContainers","useOnWindowScroll","useOnWindowResize","onWindowResize","cb","onScroll","enabled","result","overflow","overflowX","overflowY","prop","keys","a","b","key"],"mappings":"sCAEA,SAASA,EAAmDC,EAAaC,EAAY,CAC/E,IAAAC,EAEJ,MAAO,IAAIC,IAA8B,CACvC,OAAO,aAAaD,CAAS,EAC7BA,EAAY,OAAO,WAAW,IAAMF,EAAS,GAAGG,CAAI,EAAGF,CAAE,CAC3D,CACF,CA0CA,SAASG,EACP,CAAE,SAAAC,EAAU,OAAAC,EAAQ,SAAAC,EAAU,WAAAC,CAAW,EAAa,CAAE,SAAU,EAAG,OAAQ,GAAO,WAAY,IACxF,CACR,MAAMC,EACJF,IAAa,OAAO,QAAW,YAAc,KAAqB,CAAA,EAAM,OAAe,gBAEzF,GAAI,CAACE,EACH,MAAM,IAAI,MACR,gJACF,EAGF,KAAM,CAACC,EAAQC,CAAG,EAAIC,WAAuB,CAC3C,KAAM,EACN,IAAK,EACL,MAAO,EACP,OAAQ,EACR,OAAQ,EACR,MAAO,EACP,EAAG,EACH,EAAG,CAAA,CACJ,EAGKC,EAAQC,EAAAA,OAAc,CAC1B,QAAS,KACT,iBAAkB,KAClB,eAAgB,KAChB,WAAYJ,EACZ,mBAAoB,IAAA,CACrB,EAGKK,EAAiBV,EAAY,OAAOA,GAAa,SAAWA,EAAWA,EAAS,OAAU,KAC1FW,EAAiBX,EAAY,OAAOA,GAAa,SAAWA,EAAWA,EAAS,OAAU,KAG1FY,EAAUH,SAAO,EAAK,EAC5BI,EAAAA,UAAU,KACRD,EAAQ,QAAU,GACX,IAAM,KAAMA,EAAQ,QAAU,IACtC,EAGD,KAAM,CAACE,EAAcC,EAAcC,CAAY,EAAIC,UAAQ,IAAM,CAC/D,MAAMtB,EAAW,IAAM,CACjB,GAAA,CAACa,EAAM,QAAQ,QAAS,OAC5B,KAAM,CAAE,KAAAU,EAAM,IAAAC,EAAK,MAAAC,EAAO,OAAAC,EAAQ,OAAA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AqBL,EAAsD,CAClF,MAAMY,EAA6B,CAAC,EACpC,GAAI,CAACZ,GAAWA,IAAY,SAAS,KAAa,OAAAY,EAClD,KAAM,CAAE,SAAAC,EAAU,UAAAC,EAAW,UAAAC,CAAc,EAAA,OAAO,iBAAiBf,CAAO,EAC1E,MAAI,CAACa,EAAUC,EAAWC,CAAS,EAAE,KAAMC,GAASA,IAAS,QAAUA,IAAS,QAAQ,GAAGJ,EAAO,KAAKZ,CAAO,EACvG,CAAC,GAAGY,EAAQ,GAAGP,EAAqBL,EAAQ,aAAa,CAAC,CACnE,CAGA,MAAMiB,EAA+B,CAAC,IAAK,IAAK,MAAO,SAAU,OAAQ,QAAS,QAAS,QAAQ,EAC7FnB,EAAiB,CAACoB,EAAiBC,IAA6BF,EAAK,MAAOG,GAAQF,EAAEE,CAAG,IAAMD,EAAEC,CAAG,CAAC"}
|
||||
34
node_modules/react-use-measure/dist/index.d.ts
generated
vendored
Normal file
34
node_modules/react-use-measure/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
declare type ResizeObserverCallback = (entries: any[], observer: ResizeObserver) => void;
|
||||
declare class ResizeObserver {
|
||||
constructor(callback: ResizeObserverCallback);
|
||||
observe(target: Element, options?: any): void;
|
||||
unobserve(target: Element): void;
|
||||
disconnect(): void;
|
||||
static toString(): string;
|
||||
}
|
||||
export interface RectReadOnly {
|
||||
readonly x: number;
|
||||
readonly y: number;
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly top: number;
|
||||
readonly right: number;
|
||||
readonly bottom: number;
|
||||
readonly left: number;
|
||||
[key: string]: number;
|
||||
}
|
||||
type HTMLOrSVGElement = HTMLElement | SVGElement;
|
||||
type Result = [(element: HTMLOrSVGElement | null) => void, RectReadOnly, () => void];
|
||||
export type Options = {
|
||||
debounce?: number | {
|
||||
scroll: number;
|
||||
resize: number;
|
||||
};
|
||||
scroll?: boolean;
|
||||
polyfill?: {
|
||||
new (cb: ResizeObserverCallback): ResizeObserver;
|
||||
};
|
||||
offsetSize?: boolean;
|
||||
};
|
||||
declare function useMeasure({ debounce, scroll, polyfill, offsetSize }?: Options): Result;
|
||||
export default useMeasure;
|
||||
2
node_modules/react-use-measure/dist/index.js
generated
vendored
Normal file
2
node_modules/react-use-measure/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import{useState as T,useRef as p,useEffect as u,useMemo as M}from"react";function g(n,t){let o;return(...i)=>{window.clearTimeout(o),o=window.setTimeout(()=>n(...i),t)}}function j({debounce:n,scroll:t,polyfill:o,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const a=o||(typeof window=="undefined"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[c,h]=T({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),e=p({element:null,scrollContainers:null,resizeObserver:null,lastBounds:c,orientationHandler:null}),d=n?typeof n=="number"?n:n.scroll:null,f=n?typeof n=="number"?n:n.resize:null,w=p(!1);u(()=>(w.current=!0,()=>void(w.current=!1)));const[z,m,s]=M(()=>{const r=()=>{if(!e.current.element)return;const{left:y,top:C,width:H,height:O,bottom:S,right:x,x:B,y:R}=e.current.element.getBoundingClientRect(),l={left:y,top:C,width:H,height:O,bottom:S,right:x,x:B,y:R};e.current.element instanceof HTMLElement&&i&&(l.height=e.current.element.offsetHeight,l.width=e.current.element.offsetWidth),Object.freeze(l),w.current&&!D(e.current.lastBounds,l)&&h(e.current.lastBounds=l)};return[r,f?g(r,f):r,d?g(r,d):r]},[h,i,d,f]);function v(){e.current.scrollContainers&&(e.current.scrollContainers.forEach(r=>r.removeEventListener("scroll",s,!0)),e.current.scrollContainers=null),e.current.resizeObserver&&(e.current.resizeObserver.disconnect(),e.current.resizeObserver=null),e.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",e.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",e.current.orientationHandler))}function b(){e.current.element&&(e.current.resizeObserver=new a(s),e.current.resizeObserver.observe(e.current.element),t&&e.current.scrollContainers&&e.current.scrollContainers.forEach(r=>r.addEventListener("scroll",s,{capture:!0,passive:!0})),e.current.orientationHandler=()=>{s()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",e.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",e.current.orientationHandler))}const L=r=>{!r||r===e.current.element||(v(),e.current.element=r,e.current.scrollContainers=E(r),b())};return X(s,!!t),W(m),u(()=>{v(),b()},[t,s,m]),u(()=>v,[]),[L,c,z]}function W(n){u(()=>{const t=n;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[n])}function X(n,t){u(()=>{if(t){const o=n;return window.addEventListener("scroll",o,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",o,!0)}},[n,t])}function E(n){const t=[];if(!n||n===document.body)return t;const{overflow:o,overflowX:i,overflowY:a}=window.getComputedStyle(n);return[o,i,a].some(c=>c==="auto"||c==="scroll")&&t.push(n),[...t,...E(n.parentElement)]}const k=["x","y","top","bottom","left","right","width","height"],D=(n,t)=>k.every(o=>n[o]===t[o]);export{j as default};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/react-use-measure/dist/index.js.map
generated
vendored
Normal file
1
node_modules/react-use-measure/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":null,"names":["createDebounce","callback","ms","timeoutId","args","useMeasure","debounce","scroll","polyfill","offsetSize","ResizeObserver","bounds","set","useState","state","useRef","scrollDebounce","resizeDebounce","mounted","useEffect","forceRefresh","resizeChange","scrollChange","useMemo","left","top","width","height","bottom","right","x","y","size","areBoundsEqual","removeListeners","element","addListeners","scrollContainer","ref","node","findScrollContainers","useOnWindowScroll","useOnWindowResize","onWindowResize","cb","onScroll","enabled","result","overflow","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A,CAAE,SAAAC,EAAU,UAAAC,EAAW,UAAAC,CAAc,EAAA,OAAO,iBAAiBf,CAAO,EACtE,MAAA,CAACa,EAAUC,EAAWC,CAAS,EAAE,KAAMC,GAASA,IAAS,QAAUA,IAAS,QAAQ,GAAGJ,EAAO,KAAKZ,CAAO,EACvG,CAAC,GAAGY,EAAQ,GAAGP,EAAqBL,EAAQ,aAAa,CAAC,CACnE,CAGA,MAAMiB,EAA+B,CAAC,IAAK,IAAK,MAAO,SAAU,OAAQ,QAAS,QAAS,QAAQ,EAC7FnB,EAAiB,CAACoB,EAAiBC,IAA6BF,EAAK,MAAOG,GAAQF,EAAEE,CAAG,IAAMD,EAAEC,CAAG,CAAC"}
|
||||
65
node_modules/react-use-measure/package.json
generated
vendored
Normal file
65
node_modules/react-use-measure/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "react-use-measure",
|
||||
"version": "2.1.7",
|
||||
"description": "Utility to measure view bounds",
|
||||
"keywords": [
|
||||
"react",
|
||||
"use",
|
||||
"measure",
|
||||
"bounds",
|
||||
"hooks"
|
||||
],
|
||||
"author": "Paul Henschel",
|
||||
"homepage": "https://github.com/pmndrs/react-use-measure",
|
||||
"repository": "https://github.com/pmndrs/react-use-measure",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist/*",
|
||||
"src/*"
|
||||
],
|
||||
"type": "module",
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"devDependencies": {
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/react": "^16.2.0",
|
||||
"@types/node": "^22.12.0",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"@vitest/browser": "^3.0.4",
|
||||
"playwright": "^1.50.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"resize-observer-polyfill": "^1.5.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"typescript": "^5.7.3",
|
||||
"vite": "^6.0.11",
|
||||
"vitest": "^3.0.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.13",
|
||||
"react-dom": ">=16.13"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "rimraf dist && vite build && tsc",
|
||||
"test": "npx playwright install && vitest run"
|
||||
}
|
||||
}
|
||||
229
node_modules/react-use-measure/src/index.ts
generated
vendored
Normal file
229
node_modules/react-use-measure/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,229 @@
|
||||
import { useEffect, useState, useRef, useMemo } from 'react'
|
||||
|
||||
function createDebounce<T extends (...args: any[]) => void>(callback: T, ms: number) {
|
||||
let timeoutId: number
|
||||
|
||||
return (...args: Parameters<T>): void => {
|
||||
window.clearTimeout(timeoutId)
|
||||
timeoutId = window.setTimeout(() => callback(...args), ms)
|
||||
}
|
||||
}
|
||||
|
||||
declare type ResizeObserverCallback = (entries: any[], observer: ResizeObserver) => void
|
||||
declare class ResizeObserver {
|
||||
constructor(callback: ResizeObserverCallback)
|
||||
observe(target: Element, options?: any): void
|
||||
unobserve(target: Element): void
|
||||
disconnect(): void
|
||||
static toString(): string
|
||||
}
|
||||
|
||||
export interface RectReadOnly {
|
||||
readonly x: number
|
||||
readonly y: number
|
||||
readonly width: number
|
||||
readonly height: number
|
||||
readonly top: number
|
||||
readonly right: number
|
||||
readonly bottom: number
|
||||
readonly left: number
|
||||
[key: string]: number
|
||||
}
|
||||
|
||||
type HTMLOrSVGElement = HTMLElement | SVGElement
|
||||
|
||||
type Result = [(element: HTMLOrSVGElement | null) => void, RectReadOnly, () => void]
|
||||
|
||||
type State = {
|
||||
element: HTMLOrSVGElement | null
|
||||
scrollContainers: HTMLOrSVGElement[] | null
|
||||
resizeObserver: ResizeObserver | null
|
||||
lastBounds: RectReadOnly
|
||||
orientationHandler: null | (() => void)
|
||||
}
|
||||
|
||||
export type Options = {
|
||||
debounce?: number | { scroll: number; resize: number }
|
||||
scroll?: boolean
|
||||
polyfill?: { new (cb: ResizeObserverCallback): ResizeObserver }
|
||||
offsetSize?: boolean
|
||||
}
|
||||
|
||||
function useMeasure(
|
||||
{ debounce, scroll, polyfill, offsetSize }: Options = { debounce: 0, scroll: false, offsetSize: false },
|
||||
): Result {
|
||||
const ResizeObserver =
|
||||
polyfill || (typeof window === 'undefined' ? class ResizeObserver {} : (window as any).ResizeObserver)
|
||||
|
||||
if (!ResizeObserver) {
|
||||
throw new Error(
|
||||
'This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills',
|
||||
)
|
||||
}
|
||||
|
||||
const [bounds, set] = useState<RectReadOnly>({
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
x: 0,
|
||||
y: 0,
|
||||
})
|
||||
|
||||
// keep all state in a ref
|
||||
const state = useRef<State>({
|
||||
element: null,
|
||||
scrollContainers: null,
|
||||
resizeObserver: null,
|
||||
lastBounds: bounds,
|
||||
orientationHandler: null,
|
||||
})
|
||||
|
||||
// set actual debounce values early, so effects know if they should react accordingly
|
||||
const scrollDebounce = debounce ? (typeof debounce === 'number' ? debounce : debounce.scroll) : null
|
||||
const resizeDebounce = debounce ? (typeof debounce === 'number' ? debounce : debounce.resize) : null
|
||||
|
||||
// make sure to update state only as long as the component is truly mounted
|
||||
const mounted = useRef(false)
|
||||
useEffect(() => {
|
||||
mounted.current = true
|
||||
return () => void (mounted.current = false)
|
||||
})
|
||||
|
||||
// memoize handlers, so event-listeners know when they should update
|
||||
const [forceRefresh, resizeChange, scrollChange] = useMemo(() => {
|
||||
const callback = () => {
|
||||
if (!state.current.element) return
|
||||
const { left, top, width, height, bottom, right, x, y } =
|
||||
state.current.element.getBoundingClientRect() as unknown as RectReadOnly
|
||||
|
||||
const size = {
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height,
|
||||
bottom,
|
||||
right,
|
||||
x,
|
||||
y,
|
||||
}
|
||||
|
||||
if (state.current.element instanceof HTMLElement && offsetSize) {
|
||||
size.height = state.current.element.offsetHeight
|
||||
size.width = state.current.element.offsetWidth
|
||||
}
|
||||
|
||||
Object.freeze(size)
|
||||
if (mounted.current && !areBoundsEqual(state.current.lastBounds, size)) set((state.current.lastBounds = size))
|
||||
}
|
||||
return [
|
||||
callback,
|
||||
resizeDebounce ? createDebounce(callback, resizeDebounce) : callback,
|
||||
scrollDebounce ? createDebounce(callback, scrollDebounce) : callback,
|
||||
]
|
||||
}, [set, offsetSize, scrollDebounce, resizeDebounce])
|
||||
|
||||
// cleanup current scroll-listeners / observers
|
||||
function removeListeners() {
|
||||
if (state.current.scrollContainers) {
|
||||
state.current.scrollContainers.forEach((element) => element.removeEventListener('scroll', scrollChange, true))
|
||||
state.current.scrollContainers = null
|
||||
}
|
||||
|
||||
if (state.current.resizeObserver) {
|
||||
state.current.resizeObserver.disconnect()
|
||||
state.current.resizeObserver = null
|
||||
}
|
||||
|
||||
if (state.current.orientationHandler) {
|
||||
if ('orientation' in screen && 'removeEventListener' in screen.orientation) {
|
||||
screen.orientation.removeEventListener('change', state.current.orientationHandler)
|
||||
} else if ('onorientationchange' in window) {
|
||||
window.removeEventListener('orientationchange', state.current.orientationHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add scroll-listeners / observers
|
||||
function addListeners() {
|
||||
if (!state.current.element) return
|
||||
state.current.resizeObserver = new ResizeObserver(scrollChange)
|
||||
state.current.resizeObserver!.observe(state.current.element)
|
||||
if (scroll && state.current.scrollContainers) {
|
||||
state.current.scrollContainers.forEach((scrollContainer) =>
|
||||
scrollContainer.addEventListener('scroll', scrollChange, { capture: true, passive: true }),
|
||||
)
|
||||
}
|
||||
|
||||
// Handle orientation changes
|
||||
state.current.orientationHandler = () => {
|
||||
scrollChange()
|
||||
}
|
||||
|
||||
// Use screen.orientation if available
|
||||
if ('orientation' in screen && 'addEventListener' in screen.orientation) {
|
||||
screen.orientation.addEventListener('change', state.current.orientationHandler)
|
||||
} else if ('onorientationchange' in window) {
|
||||
// Fallback to orientationchange event
|
||||
window.addEventListener('orientationchange', state.current.orientationHandler)
|
||||
}
|
||||
}
|
||||
|
||||
// the ref we expose to the user
|
||||
const ref = (node: HTMLOrSVGElement | null) => {
|
||||
if (!node || node === state.current.element) return
|
||||
removeListeners()
|
||||
state.current.element = node
|
||||
state.current.scrollContainers = findScrollContainers(node)
|
||||
addListeners()
|
||||
}
|
||||
|
||||
// add general event listeners
|
||||
useOnWindowScroll(scrollChange, Boolean(scroll))
|
||||
useOnWindowResize(resizeChange)
|
||||
|
||||
// respond to changes that are relevant for the listeners
|
||||
useEffect(() => {
|
||||
removeListeners()
|
||||
addListeners()
|
||||
}, [scroll, scrollChange, resizeChange])
|
||||
|
||||
// remove all listeners when the components unmounts
|
||||
useEffect(() => removeListeners, [])
|
||||
return [ref, bounds, forceRefresh]
|
||||
}
|
||||
|
||||
// Adds native resize listener to window
|
||||
function useOnWindowResize(onWindowResize: (event: Event) => void) {
|
||||
useEffect(() => {
|
||||
const cb = onWindowResize
|
||||
window.addEventListener('resize', cb)
|
||||
return () => void window.removeEventListener('resize', cb)
|
||||
}, [onWindowResize])
|
||||
}
|
||||
function useOnWindowScroll(onScroll: () => void, enabled: boolean) {
|
||||
useEffect(() => {
|
||||
if (enabled) {
|
||||
const cb = onScroll
|
||||
window.addEventListener('scroll', cb, { capture: true, passive: true })
|
||||
return () => void window.removeEventListener('scroll', cb, true)
|
||||
}
|
||||
}, [onScroll, enabled])
|
||||
}
|
||||
|
||||
// Returns a list of scroll offsets
|
||||
function findScrollContainers(element: HTMLOrSVGElement | null): HTMLOrSVGElement[] {
|
||||
const result: HTMLOrSVGElement[] = []
|
||||
if (!element || element === document.body) return result
|
||||
const { overflow, overflowX, overflowY } = window.getComputedStyle(element)
|
||||
if ([overflow, overflowX, overflowY].some((prop) => prop === 'auto' || prop === 'scroll')) result.push(element)
|
||||
return [...result, ...findScrollContainers(element.parentElement)]
|
||||
}
|
||||
|
||||
// Checks if element boundaries are equal
|
||||
const keys: (keyof RectReadOnly)[] = ['x', 'y', 'top', 'bottom', 'left', 'right', 'width', 'height']
|
||||
const areBoundsEqual = (a: RectReadOnly, b: RectReadOnly): boolean => keys.every((key) => a[key] === b[key])
|
||||
|
||||
export default useMeasure
|
||||
Reference in New Issue
Block a user