0.1.2 • Published 5 months ago

react-peel v0.1.2

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

React Peel

react-peel is a React library that serves as a wrapper around the peel.js library created by Andrew Plummer.

The library allows you to create realistic peeling effects in your React applications. It comes with a set of props and events to customize and control the peeling behavior.

Check out the docs at https://react-peel.vercel.app

Installation

To install react-peel in your project, use the following command:

npm install react-peel

Basic usage

import React from "react";
import { PeelWrapper, PeelTop, PeelBottom, PeelBack } from "react-peel";

const MyComponent = () => {
  return (
    <PeelWrapper height={200} width={200} drag>
      <PeelTop style={{ backgroundColor: "#81afcb" }}></PeelTop>
      <PeelBack style={{ backgroundColor: "#a0c7df" }}></PeelBack>
      <PeelBottom style={{ backgroundColor: "#688394" }}></PeelBottom>
    </PeelWrapper>
  );
};

export default MyComponent;

This basic example demonstrates how to set up a peel effect using react-peel. You can customize the appearance, size, and behavior of the peel by adjusting the props and styles passed to the components within the PeelWrapper.

PeelWrapper Props

The PeelWrapper component provides the following props to customize the peeling effect:

PropsTypeNote
refMutableRefObject<any> \| undefinedReference to the Peel object, containing values and methods.
classNamestring \| undefinedRepresents the class of PeelWrapper.
heightstring \| undefinedSets the height of PeelWrapper.
widthstring \| undefinedSets the width of PeelWrapper.
optionsobject \| undefinedOptions to pass to the underlying peel.js constructor. See options here.
peelPosition{ x: number, y: number } \| undefinedThe position of the peel effect. This point is the position of the corner that is being peeled back.
corner{ x: number, y: number } \| "TOP_LEFT" \| "TOP_RIGHT" \| "BOTTOM_LEFT" \| "BOTTOM_RIGHT" \| undefinedThe corner for the effect to peel back from. Can be 2 arguments as x,y coordinates or a single argument as a corner name. Default is the bottom right corner.
constraints{ x: number, y: number } \| "TOP_LEFT" \| "TOP_RIGHT" \| "BOTTOM_LEFT" \| "BOTTOM_RIGHT" \| undefined \| Array<{ x: number, y: number } \| "TOP_LEFT" \| "TOP_RIGHT" \| "BOTTOM_LEFT" \| "BOTTOM_RIGHT" \| undefined>List of constraints on the distance of the peel. Can be 2 arguments as x,y coordinates or a single argument as a corner name.
dragboolean \| undefinedA shorthand for setting the @drag event to set the peel position to the mouse.
mode"book" \| "calendar" \| undefinedA shortcut for setting predefined constraints. Currently "book" and "calendar".
fadeThresholdnumber \| undefinedA threshold above which the top layer will begin to fade out. The threshold is between 0 (no peel) and 1 (top layer is fully peeled off).
timeAlongPathnumber \| undefinedSets the peel effect to a point in time (between 0 and 1) along a previously specified path. Will throw an error if no path exists.
peelPathnumber[] \| undefinedA path along which the peel will follow. This can be a flat line segment or a bezier curve.

Contribution

Contributions are welcome! Feel free to check out the Contributing Guide before making a pull request.

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago