0.0.3 • Published 5 years ago

use-rotator v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

useRotator

Rotate an element with a handle

import React from "react";
import useRotator from "use-rotator";

function App() {
  const [rotatableRef, handleRef, degree, isDragging] = useRotator(0, true);
  return (
    <div>
      isDragging: {isDragging.toString()}
      <div ref={handleRef} style={{ cursor: "grab", userSelect: "none" }}>
        Grab me to rotate
      </div>
      <div
        ref={rotatableRef}
        style={{ display: "inline-block", transform: `rotate(${degree}deg)` }}
      >
        I can be rotated!
      </div>
    </div>
  );
}

Live: https://codesandbox.io/s/userotator-demo-0o722