react-simple-draggable

A simple draggable component for react


Keywords
react, draggable, drag, useful component, react-component
License
MIT
Install
npm install react-simple-draggable@1.0.1

Documentation

react-simple-draggable

Description

This is s pure and simple draggable component for react.

How to use

import React from "react";
import Draggable from "react-simple-draggable";

class XXX extends React.Component {
  render() {
    let controll = {
        left:XXX,
        right:XXX,
        top:XXX,
        buttom:XXX,
    };
    return (
      <Draggable controled={controll}>
        <div></div>
      </Draggable>
    );
  }
}

See the demo

###Tips

If you use it to contain your another component ,you can get a couple of value of position and you can get them by props
import React from "react";
import Draggable from "react-simple-draggable";

class XXX extends React.Component {
  render() {
    let controll = {
        left:XXX,
        right:XXX,
        top:XXX,
        buttom:XXX,
    };
    return (
      <Draggable controled={controll}>
         <yourComponent></yourComponent>
      </Draggable>
    );
  }
}

import React from "react";
import Draggable from "react-simple-draggable";

class yourComponent extends React.Component {
  constructor() {
    super();
  }
  render() {
    const { x, y } = this.props.movedPosition
    return (
        ...
    );
  }
}