0.0.7 • Published 15 days ago

@astii/resizable v0.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
15 days ago

@astii/resizable

NPM version NPM downloads

Install

$ yarn install @astii/resizable

Usage

import React, { useState } from "react";
import { Resizable } from "@astii/resizable";

export default () => {
  const [style, setStyle] = useState<React.CSSProperties>({
    width: 200,
    height: 200,
    backgroundColor: "red",
  });

  const onResize = ({width, height}) => {
    setStyle(pre => ({...pre, width, height}))
  }
  return (
    <Resizable onResize={onResize} >
      <div style={style}></div>
    </Resizable>
  );
};

Options

interface ResizableProps {
  axis?: "x" | "y" | "both";  //resize direction
  zoom?: number;   //scaling
  onResizeStart?: () => void;  //Executed when dragging starts
  onResize?: (size: {
    width: CSSProperties["width"];
    height: CSSProperties["height"];
  }) => void;  //Executed when dragging
  onResizeStop?: () => void;  //Executed when dragging ends
  children: ReactElement<any, string | JSXElementConstructor<any>>;
  className?: string;
}

LICENSE

MIT

0.0.7

15 days ago

0.0.6

15 days ago

0.0.5

3 months ago

0.0.4

7 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago