-
Notifications
You must be signed in to change notification settings - Fork 97
V11 #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…onResize` to accept single object. Pass ResizeObserverEntry as a param
|
@maslianok It seemed to me that the existing demo was created quite a while ago, hastily put together, and had become very outdated. Additionally, I've implemented a couple of changes to the internal logic that I hadn’t had the chance to address for a long time. Please take a look when you have a moment. Thank you! |
|
New playground demo: Existing demo for comparison: |
|
Thank you so much!!!! What a great job, @snelsi ❤️ |
|
@maslianok Don't forget to update https://maslianok.github.io/react-resize-detector/ to use the new playground app |
## [1.0.4](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.0.4) (2024-10-10) ### Bug Fixes * bump react-resize-detector from 10.0.1 to 11.0.1 in /typescript ([#2305](#2305)) ([80f879e](80f879e)), closes [maslianok/react-resize-detector#254](maslianok/react-resize-detector#254)
## [1.5.8](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.5.8) (2024-10-10) ### Bug Fixes * bump react-resize-detector from 10.0.1 to 11.0.1 in /typescript ([#2305](#2305)) ([80f879e](80f879e)), closes [maslianok/react-resize-detector#254](maslianok/react-resize-detector#254)
## [1.0.5](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.0.5) (2024-10-10) ### Bug Fixes * bump react-resize-detector from 10.0.1 to 11.0.1 in /typescript ([#2305](#2305)) ([80f879e](80f879e)), closes [maslianok/react-resize-detector#254](maslianok/react-resize-detector#254)
## [1.3.13](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@1.3.13) (2024-10-10) ### Bug Fixes * bump react-resize-detector from 10.0.1 to 11.0.1 in /typescript ([#2305](#2305)) ([80f879e](80f879e)), closes [maslianok/react-resize-detector#254](maslianok/react-resize-detector#254)
## [2.1.3](https://github.com/equinor/webviz-subsurface-components/compare/[email protected]@2.1.3) (2024-10-10) ### Bug Fixes * bump react-resize-detector from 10.0.1 to 11.0.1 in /typescript ([#2305](#2305)) ([80f879e](80f879e)), closes [maslianok/react-resize-detector#254](maslianok/react-resize-detector#254)
This PR introduces several changes to the
react-resize-detectorlibrary, including functional improvements, better handling of parameters, maintenance updates, and the addition of an interactive playground.✨ Functional Changes
onResizefunction to optimize its usage. Eliminated redundantuseEffectcalls and integrated theonResizemethod with thesetSizecall. This change was inspired by this article.onResizeparameters to accept a single object, ensuring proper handling when the element is unmounted. The function now consistently returns width and height as numbers when the element is mounted. Additionally, it now includes aResizeObserverEntryobject as the newentryprop.onResizefunction into ref to avoid rerenders when passed to a dependency arrayobserverOptions.boxparameter (Return width according to provided observerOptions #220)../typesfileReactResizeDetectorDimensionstoDimensions📄 Chore / Docs
lintandlint-fixcommands to always fix auto-fixable problems.directoriesdeclaration inpackage.json.🚀 New Interactive Playground
Demo: https://react-resize-detector.vercel.app/
The
/examplesfolder has been completely revamped. It now includes comprehensive documentation for configuration options, direct links to docs, and an interactive playground to visualize the impact of different parameters on theuseResizeDetectorbehavior. Interactive examples demonstrate the functionality ofobserverOptions.boxandrefreshMode. The codebase now includes extensive comments and explanations. Cards within the playground are resizable directly within the view, eliminating the need to resize the browser window. Each card resize is highlighted with a custom effect. The demo is built with Radix Themes.onResizefunction now receives a single object. Destructurewidthandheightparameters as follows:When the element is mounted,
widthandheightwill always be numbers. When unmounted, they will benull.Ensure to add null checks before accessing element dimensions to address TypeScript errors.
Note that
entry, a ResizeObserverEntry triggered byResizeObserver, is now accessible. This provides access toborderBoxSize,contentBoxSize, andtarget, useful for custom logic or calculating border/padding size.Refer to the ResizeObserverEntry documentation.
If
observerOptions.boxis set toborder-box, the returnedwidthandheightfrom theuseResizeDetectorhook will include the padding and border size of the element. Default behavior remains unchanged - padding and border size are not included.Rename
ReactResizeDetectorDimensionstoDimensions