This is a React hooks that observe HTML element fits within the current viewport or element.
It's the for building more complex UI.
npm install react-page-fitter
import useFitter from 'react-page-fitter'
function MyComponent() {
const pathname = // useLocation...
const isFit = useFitter('.class')
return isFit && <CustomComponents/>
}
useFitter (argument, options)
return value boolean | undefined.
Returns undefined if an invalid argument is passed.
Parameter | Meaning |
---|---|
target (required) | The judgement target element by tag, className or id |
Field | Key |
---|---|
offsetX | Horizontal viewport offsetX number when not using parentBox, The default value is 0 |
offsetY | Vertical viewport offsetY number when not using parentBox, The default value is 0 |
parentBox | The judgement parentBox element by tag, className or id is judged in place of the viewport, default undefined |
pathname | The dynamic pathname to render when placing at layout level |
The MIT License.