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

react-resizable-rotatable-draggable

Package Overview
Dependencies
Maintainers
8
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-resizable-rotatable-draggable

A rectangle react component which can be resized and rotated

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-77.02%
Maintainers
8
Weekly downloads
 
Created
Source

React-resizable-rotatable-draggable-rectangle

NPM JavaScript Style Guide

A react widget that can be resized and rotated via a handler.

Installation

npm install --save react-resizable-rotatable-draggable`

Then you will need to install peer dependency

npm install --save styled-components@4

Usage

import React, { Component } from 'react'
import ResizableRect from 'react-resizable-rotatable-draggable'

class App extends Component {
  constructor() {
    super()
    this.state = {
      width: 100,
      height: 100,
      top: 100,
      left: 100,
      rotateAngle: 0
    }
  }

  handleResize = (style, isShiftKey, type) => {
    // type is a string and it shows which resize-handler you clicked
    // e.g. if you clicked top-right handler, then type is 'tr'
    let { top, left, width, height } = style
    top = Math.round(top)
    left = Math.round(left)
    width = Math.round(width)
    height = Math.round(height)
    this.setState({
      top,
      left,
      width,
      height
    })
  }

  handleRotate = (rotateAngle) => {
    this.setState({
      rotateAngle
    })
  }

  handleDrag = (deltaX, deltaY) => {
    this.setState({
      left: this.state.left + deltaX,
      top: this.state.top + deltaY
    })
  }

  render() {
    const {width, top, left, height, rotateAngle} = this.state
    return (
      <div className="App">
        <ResizableRect
          left={left}
          top={top}
          width={width}
          height={height}
          rotateAngle={rotateAngle}
          // aspectRatio={false}
          // minWidth={10}
          // minHeight={10}
          zoomable='n, w, s, e, nw, ne, se, sw'
          // rotatable={true}
          // onRotateStart={this.handleRotateStart}
          onRotate={this.handleRotate}
          // onRotateEnd={this.handleRotateEnd}
          // onResizeStart={this.handleResizeStart}
          onResize={this.handleResize}
          // onResizeEnd={this.handleUp}
          // onDragStart={this.handleDragStart}
          onDrag={this.handleDrag}
          // onDragEnd={this.handleDragEnd}
        />
      </div>
    )
  }
}

export default App

Props

PropsTypeDefaultExample
leftnumber.isRequired10
topnumber.isRequired10
widthnumber.isRequired100
heightnumber.isRequired100
rotateAnglenumber00
rotatablebooltruetrue
zoomablestring'''n, w, s, e, nw, ne, se, sw'
minWidthnumber100
minHeightnumber100
aspectRationumber (width / height)1(which makes the rectangle a square)
onRotateStartfunc
onRotatefunc(rotateAngle)
onRotateEndfunc
onResizeStartfunc
onResizefunc(style, isShiftKey, type)
onResizeEndfunc
onDragStartfunc
onDragfunc(deltaX, deltaY)
onDragEndfunc

License

MIT © MockingBot

Keywords

FAQs

Package last updated on 18 Jan 2019

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