use-resizable
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

use-resizable

get resize value use react-hook from mousedown, mousemove, mouseup event (avaible touch event)

demo

https://codesandbox.io/s/funny-mcnulty-4f1j0

usage

import * as React from "react";
import useResizable from "use-resizable";
 
function Layout({ children }: React.PropsWithChildren<{}>) {
  const { size, handler } = useResizable({
    minSize: 300,
    maxSize: 600,
    width: 400,
    direction: "left", // size scale direction
  });
  return (
    <div style={{ width: size, position: "relative" }}>
      {children}
      <div
        style={{
          position: "absolute",
          left: "-5px",
          top: 0,
          height: "100%",
          width: "10px",
          cursor: "col-resize"
        }}
        onMouseDown={handler}
        onTouchStart={handler}
      />
    </div>
  );
}

Package Sidebar

Install

npm i use-resizable

Weekly Downloads

4

Version

1.0.5

License

ISC

Unpacked Size

11.9 kB

Total Files

9

Last publish

Collaborators

  • minukang