New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-transformable-draggable

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-transformable-draggable

A set of component wrappers to make any component or element draggable, droppable, and transformable.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

react-transformable-draggable

Description

A set of component wrappers to make any component or element draggable, droppable, and transformable.

Installation

$ npm install react-transformable-draggable
$ yarn add react-transformable-draggable

Example Usage

import React, { useState } from 'react'
import _ from 'lodash-uuid'
import {
    DeleteTarget,
    DndProvider,
    Droppable,
    Transformable,
    TransformableTarget,
} from 'react-transformable-draggable'
...

const renderItem = (
    <div className="app-render-item">
        CLICK ME
        <img src={logo} className="app-logo" alt="logo" />
        TO ADD
    </div>
)

export const Example = () => {
    const [deleteClassName, setDeleteClassName] = useState('app-delete-target')
    const [renderItems, setRenderItems] = useState([])

    const onDelete = (id, type) => {
        console.log('deleted type: ', type)
        const updatedRenderItems = renderItems.filter(item => item.id !== id)

        setRenderItems(updatedRenderItems)
    }

    const onHoverEnd = () => {
        setDeleteClassName('app-delete-target')
    }

    const onHoverStart = () => {
        setDeleteClassName('app-delete-target--hover')
    }

    return (
        <div className="app">
            <DndProvider>
                <TransformableTarget className="app-transformable-target">
                    {renderItems.map(({ id, renderItem }) => (
                        <Transformable key={id} id={id} type="CLICK_TO_ADD">
                            {renderItem}
                        </Transformable>
                    ))}
                </TransformableTarget>
                <div className="app-toolbar">
                    <DeleteTarget
                        onDelete={onDelete}
                        onHoverStart={onHoverStart}
                        onHoverEnd={onHoverEnd}
                    >
                        <div className={deleteClassName}>DRAG HERE TO DELETE</div>
                    </DeleteTarget>
                    <div className="app-add-items">
                        <Droppable type="DRAG_TO_ADD">
                            <div className="app-render-item">
                                DRAG ME
                                <img src={logo} className="app-logo" alt="logo" />
                                TO ADD
                            </div>
                        </Droppable>
                        <div
                            onClick={() =>
                                setRenderItems([...renderItems, { renderItem, id: _.uuid() }])
                            }
                        >
                            <div className="app-render-item">
                                CLICK ME
                                <img src={logo} className="app-logo" alt="logo" />
                                TO ADD
                            </div>
                        </div>
                    </div>
                </div>
            </DndProvider>
        </div>
    )
}

Props

PropDefaultDescriptionRequired
boundingBoxStyleundefinedOverride default boundingBox styling. Color/thickness set with css border property.No
boundingBoxStyleMobileundefinedOverride default boundingBox styling on mobile devices. Color/thickness set with css border property.No
hideBoundingBoxfalseHides the bounding boxNo
hideHandlesfalseHides the resize and rotation handles.No
initialPosition'center'Initial position for progrmatically added elements (non drag & drop). An object of the form {top, left} with values relative to the TransformableTarget container, or a string equal to one of the following: 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'top-center', 'bottom-center', 'left', 'right'No
lockAspectRatiofalseLocks the element's aspect ratio to that of the initial render.No
minWidth70Minimum resize width of the element.No
minHeight70Minimum resize height of the element.No
resizeHandleStyleundefinedOverride default resize handle styling. Color set with css background-color property, width/height set with CSS width/height property.No
resizeHandleStyleMobileundefinedOverride default resize handle styling on mobile devices. Color set with css background-color property, width/height set with CSS width/height property.No
rotateHandleStyleundefinedOverride default rotate handle styling. Color set with css fill property, width/height set with CSS width/height property.No
rotateHandleStyleMobileundefinedOverride default rotate handle styling. Color set with css fill property, width/height set with CSS width/height property.No

PRs Welcome!

FAQs

Package last updated on 26 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts