react-draggable-playground
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-draggable-playground

Reusable React-draggable components with render props.

Travis Codecov Status npm package npm downloads

Dependency Status devDependency Status peerDependency Status

prettier license

Installation

$ yarn add react-draggable-playground

Demo

Usage

import { DraggableParent, DraggableItem } from 'react-draggable-playground';
 
<DraggableParent height={300} width={300}>
  <DraggableItem
    defaultPosition={{ x: 100, y: 100 }}
    onPositionChange={(position: Position) => {}}
  >
    {({ isDragging }) => <div>item</div>}
  </DraggableItem>
</DraggableParent>;

API

type Position = {
  x: number,
  y: number,
};
 
// DraggableItem
type Props = {
  children: ({ isDragging: boolean, disabled: boolean }) => React.Node,
  disabled: boolean,
  onPositionChange?: Position => Promise<void> | void,
  defaultPosition?: Position,
};
 
// DraggableParent
type Props = {
  height: number,
  width: number,
  children?: React.Node,
  style?: Object,
};

Development

Requirements

  • node >= 9.8.0
  • yarn >= 1.5.1
$ yarn install --pure-lockfile
$ yarn start

Test

$ yarn run format
$ yarn run eslint
$ yarn run flow
$ yarn run test:watch
$ yarn run build

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests.

CHANGELOG

LICENSE

MIT: http://michaelhsu.mit-license.org

Readme

Keywords

Package Sidebar

Install

npm i react-draggable-playground

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

16.9 kB

Total Files

7

Last publish

Collaborators

  • evenchange4