1.0.18 • Published 5 months ago

easy-resize v1.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Easy Resize

npm

A React component that allows you to have an easily resizable container.

Installation

With npm

npm i easy-resize

With yarn

yarn add easy-resize

Props

PropTypeDefaultDescription
allowedDirectionsArray<'n'\|'s'\|'w'\|'e'\|'nw'\|'ne'\|'sw'\|'se'>['n','s','w','e','nw','ne','sw','se']Directions where resize handles should appear
minWidthnumber0Minimum width the container can be resized to
minHeightnumber0Minimum height the container can be resized to
initialWidthnumber200Initial width of the container
initialHeightnumber200Initial height of the container
lockAspectRatiobooleanfalseLocks aspect ratio when resizing
onChangeStarted(width: number, height: number) => void() => {}Callback fired when resizing is started
onChangeFinished(width: number, height: number) => void() => {}Callback fired when resizing is complete
resizeHandleReactNode<div style={{width: 10, height: 10, backgroundColor: "gray"}} />Custom resize handle for edges
cornerResizeHandleReactNodeMatches resizeHandleCustom resize handle for corners
sxCSSProperties{}Additional CSS styles for the container

Examples

Basic Usage with Custom Initial Size

import ResizableContainer from 'easy-resize'

<ResizableContainer
  initialWidth={400}
  initialHeight={300}
  minWidth={200}
  minHeight={200}
>
  <div>
    Content goes here
  </div>
</ResizableContainer>

Limiting Resize Directions

import ResizableContainer from 'easy-resize'

<ResizableContainer
  allowedDirections={['e', 'se', 's']} // Only allow resizing from right side, bottom, and bottom-right corner
>
  <div>
    Content goes here
  </div>
</ResizableContainer>

Using Custom Resize Handles

  • You can specify custom resize handles.
  • There is a basic resize handle option, and a corner resize handle option, if only the basic resize handle is defined then this will also be used for the corners.
  • Corner resize handles will automatically be rotated to be facing towards the corner.
import ResizableContainer from 'easy-resize'

<ResizableContainer
  resizeHandle={<div style={{ width: 8, height: 8, backgroundColor: 'blue' }} />}
  cornerResizeHandle={<div style={{ width: 10, height: 10, backgroundColor: 'red' }} />}
>
  <div>
    Content goes here
  </div>
</ResizableContainer>
1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.9

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago