项目作者: evenchange4

项目描述 :
Reusable React-draggable components with render props.
高级语言: JavaScript
项目地址: git://github.com/evenchange4/react-draggable-playground.git
创建时间: 2018-03-20T06:27:36Z
项目社区:https://github.com/evenchange4/react-draggable-playground

开源协议:MIT License

下载


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

  1. $ yarn add react-draggable-playground

Demo

Usage

  1. import { DraggableParent, DraggableItem } from 'react-draggable-playground';
  2. <DraggableParent height={300} width={300}>
  3. <DraggableItem
  4. defaultPosition={{ x: 100, y: 100 }}
  5. onPositionChange={(position: Position) => {}}
  6. >
  7. {({ isDragging }) => <div>item</div>}
  8. </DraggableItem>
  9. </DraggableParent>;

API

  1. type Position = {
  2. x: number,
  3. y: number,
  4. };
  5. // DraggableItem
  6. type Props = {
  7. children: ({ isDragging: boolean, disabled: boolean }) => React.Node,
  8. disabled: boolean,
  9. onPositionChange?: Position => Promise<void> | void,
  10. defaultPosition?: Position,
  11. };
  12. // DraggableParent
  13. type Props = {
  14. height: number,
  15. width: number,
  16. children?: React.Node,
  17. style?: Object,
  18. };

Development

Requirements

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

Test

  1. $ yarn run format
  2. $ yarn run eslint
  3. $ yarn run flow
  4. $ yarn run test:watch
  5. $ 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