0.2.0 • Published 1 year ago

react-debounce-resize v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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

PropTypeDefaultDescription
fallbackReactNodeFallback content shown while resizing is happening.
debounceMillisecondsnumber300How long to wait before assuming resize has ended.
debounceIfReducedMotionPreferredToobooleanfalseApply debounce even if user agent prefers reduced motion.
unmountContentWhileResizingbooleanfalseRemove main from DOM while resizing.
disableCrossFadebooleanfalseDisable 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.
0.2.0

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago