1.0.8 • Published 5 months ago

react-drag-mobile-drawer v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

react-drag-mobile-drawer

npm package

Mobile draggable drawer that falls back to modals on desktop

This is an updated fork of the original react-drag-drawer with some additional APIs and updated dependencies

Live demo!

Install

$ npm i react-drag-mobile-drawer

Usage

import Drawer from 'react-drag-mobile-drawer'

..

toggle = () => {
  let { toggle } = this.state

  this.setState({ toggle: !toggle })
}

render () {
  const { open } = this.state

  return (
    <Drawer
      open={open}
      onRequestClose={this.toggle}
    >
      <div>Hey Im inside the drawer!</div>
    </Drawer>
  )
}

API

ParamTypefunctionalityrequired
allowCloseBooleanblock closing if allowClose={false}, default is truefalse
childrenNodenulltrue
containerElementClassStringclassName to be applied to the drawer container elementfalse
containerOpacityNumberControls the container's opacity (default 0.6)false
directionStringdirection to translate drawerfalse
disableBackDropBooleanDisables the backdrop/background and allows for background scrollingfalse
dontApplyListenersBooleanskip applying internal event listeners to the domfalse
getContainerRefFunctionget container (overlay) reffalse
getModalRefFunctionget modal (draggable element) reffalse
inViewportChangeFunctiondetect when drawer is at top of viewportfalse
modalElementClassStringclassName to be applied to top elementfalse
notifyWillCloseFunctionnotify consumer if the drawer will close at touch releasefalse
onDragFunctioninvoked on dragfalse
onOpenFunctioninvoked on drawer focusfalse
openBooleannulltrue
onRequestCloseFunctionnulltrue
parentElementrefblock scrolls on element if you're not using body scrollingfalse

Example modal style

.modal {
  outline: none;
  background: white;
  font-size: 1.6rem;
  width: 76rem;
  max-width: 90%;
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  z-index: 15;
  min-height: 47rem;

  will-change: transform;
  transform: translate3d(0, 0, 0);
}

@media (max-width: 768px) {
  .modal {
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
  }
}

License

MIT © Teo Kai Xiang (this maintained fork) and Jack Hanford (Original author)

1.0.8

5 months ago

1.0.71

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.51

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago