Code Monkey home page Code Monkey logo

react-drag-it's Introduction

React Drag It

This is a react component for using draggable components in your React App. It offers easy implementation with upto date and optimized performance.

Steps To Setup and use

Once installed, make sure to wrap your ReactDragIt component inside a parent element of a defined width and height to assign a dragable area to the ReactDragIt Component. Make sure to pass a ref of parent element to the ReactDragIt component

Import the package and use it around your custom components

import React, { useRef } from 'react';
import ReactDragIt from "react-drag-it";

export default function App() {
    const parentRef = useRef(null);

    return (
        <div ref={parentRef} 
            // A defined width and height will assign a dragable area to ReactDragIt
            style={{
                width: "100vw",
                height: "100vh",
                position: "relative"
            }} 
        >
            <ReactDragIt parentRef={parentRef}>
                {/* Provide a draggable component */}

                <div style={{width: 100, height: 100, backgroundColor: "green"}}>
                    Drag Me
                </div>
            </ReactDragIt>
        </div>
    );
}

Props

  • RefObject

    • Required: true
    • type: React.RefObject
    • Description: Reference of parent element
  • disableRipple

    • Required: false
    • type: boolean
    • default: false
    • Description: Disables ripple effect
  • children

    • Required: false
    • type: JSX.Element
    • Description: Assigns a dragable component

react-drag-it's People

Contributors

waleed065 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.