react-debounce-resize
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

React debounce resize npm npm type definitions

screencast

Debounce element resize by showing pending state. Try interactive Storybook demo.

Installation

npm install react-debounce-resize

How to use

import { SwipeAction } from 'react-debounce-resize'
import 'react-debounce-resize/dist/index.css'

const App = () => {
	return (
		<DebounceResize fallback="Redrawing…">
			Your content here. E.g. a chart which is computationally intensive when
			resized.
		</DebounceResize>
	)
}

Props

Prop Type Default Description
fallback ReactNode Fallback content shown while resizing is happening.
debounceMilliseconds number 300 How long to wait before assuming resize has ended.
debounceIfReducedMotionPreferredToo boolean false Apply debounce even if user agent prefers reduced motion.
unmountContentWhileResizing boolean false Remove main from DOM while resizing.
disableCrossFade boolean false Disable fade in and out of main and fallback content.

Other exported helpers

  • useMedia: Can be used to detect media query changes.
  • usePrefersReducedMotion: Can be used to detect if user prefers reduced motion.
  • useDebounceResize: Handles the logic of <DebounceResize> without visual effects.

Package Sidebar

Install

npm i react-debounce-resize

Weekly Downloads

11

Version

0.2.0

License

ISC

Unpacked Size

19.6 kB

Total Files

21

Last publish

Collaborators

  • onset