New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-morphable

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-morphable

A resizable, rotatable and draggable div as a component for React

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

React-Morphable

View the Demo

A simple div that can be resized, rotated and / or dragged.

You can either use the <Morphable> element directly, without taking care about the position / size / rotation state of the div (while still getting access to it), or <MorphableCore> if you want the control of position / size / rotation state.

Installation

Using npm:

$ npm install --save react-morphable

Usage

import { Morphable, MorphableCore } from 'react-morphable';

render() {
  return (
    <Morphable>
      // children
    </Morphable>
  );

  // or

  return (
    <MorphableCore
      position={this.state.position}
      size={this.state.size}
      rotation={this.state.rotation}
    >
      // children
    </MorphableCore>
  );

}

Props

These props apply only to <MorphableCore>.

PropTypeDefault
position{ width: number, height: number }{ width: 150, height: 150 }
size{ x: number, y: number }{ x: 0, y: 0}
rotationnumber0

These props apply to both <MorphableCore> and <Morphable>. Note regarding CSS classes : react-morphable uses React-JSS, therefore it's not feasible to edit directly the class of a div as the class name is not fixed. That's why the prop classProps has been added (classes prop is already taken by react-JSS, we couldn't use it), thanks to which you can give any class name you want to any HTML element inside react-morphable, allowing to customize anything.

PropTypeDefault
childrenReact.Elementany
isMorphablebooltrue
lockAspectRatioboolfalse
disableDragboolfalse
disableResizeboolfalse
disableRotationboolfalse
disableGuidesbooltrue
disableBounds{forDrag: forResize: true}{forDrag: true, forResize: true (always, not yet set-up)}
bounds{top: left: bottom: right: }{ top: 0, left: 0, bottom: 0, right: 0 }
magnetismGrids{ drag: resize: rotation: } { drag: 5, resize: 5, rotation: 5 }
debugboolfalse
onHandleMouseDownfunc({ e })void
onDragStartfunc({ e })void
onDragfunc({ e, x, y })void
onDragStopfunc({ e })void
onResizeStartfunc({ e })void
onResizefunc({ e, x, y, width, height })void
onResizeStopfunc({ e })void
onRotateStartfunc({ e })void
onRotatefunc({ e, rotation })void
onRotateEndfunc({ e })void
styles{ root: , rootTransformed: , corner: , topLeftCorner: , topRightCorner: , bottomLeftCorner: , bottomRightCorner: , middleTopCorner: , middleRightCorner: , middleBottomCorner: , middleLeftCorner: , middleTopAboveCorner: }void
classProps{ root: , rootTransformed: , corner: , topLeftCorner: , topRightCorner: , bottomLeftCorner: , bottomRightCorner: , middleTopCorner: , middleRightCorner: , middleBottomCorner: , middleLeftCorner: , middleTopAboveCorner: }void

To-do

  • styles
  • classes
  • bounds for drag
  • bounds for resize
  • minimum height, minimum width
  • accessibility
  • refactoring ?

Keywords

FAQs

Package last updated on 17 Jun 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc