1.0.0 • Published 1 year ago

@drake-design-studio/react-drag-it v1.0.0

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

React Drag It!

codecov GitHub Workflow Status npm version License: MIT

This is a TypeScript implementation of the React Draggable library. It is designed to work with React 17 and higher and is compatible with both TypeScript and JavaScript projects.

Features

  • TypeScript support
  • Compatible with React 17 and higher
  • Includes a Storybook example

Installation

To install this library, you can use npm:

npm install @drake-design-studio/react-drag-it

or yarn:

yarn add @drake-design-studio/react-drag-it

Usage

Then, you can use it in your component:

import React from "react";
import { DragIt } from "@drake-design-studio/react-drag-it";

<DragIt axis="both">
  <div>Your draggable content here</div>
</DragIt>;

API

The DragIt component accepts the following props:

PropDescription
axisDetermines which axis the draggable can move. Can be "x", "y", "both", or "none".
bufferAdds some draggable buffer space around the draggable component.
handleSelector to be used as the handle that initiates drag.
defaultPositionThe default position of the draggable component.
positionThe controlled position of the draggable component.
gridSpecifies the increments by which the draggable should move.
scaleScale factor for the draggable movement.
onStartCallback when dragging starts.
onDragCallback when dragging.
onStopCallback when dragging stops.

Examples

You can find examples of how to use the DragIt component in the DragIt.stories.tsx file.

Development

To start the development server for Storybook, run:

yarn run storybook

Testing

To run the tests for the DragIt component, run:

yarn test

Contributing

Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

1.0.0

1 year ago