# react-universal-tilt

> universal-tilt.js implementation for React component

Latest version **1.3.1** (published 2019-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-universal-tilt
pnpm add react-universal-tilt
yarn add react-universal-tilt
bun add react-universal-tilt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2019-07-28 |
| First published | 2018-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jakub Biesiada |
| Maintainers | jbiesiada |
| Keywords | React, component, tilt, parallax, movement, gyroscope |

## Links

- npm: https://www.npmjs.com/package/react-universal-tilt
- Repository: https://github.com/JB1905/react-universal-tilt
- Homepage: https://github.com/JB1905/react-universal-tilt#readme
- Issues: https://github.com/JB1905/react-universal-tilt/issues
- npm.io page: https://npm.io/package/react-universal-tilt

## Dependencies (1)

- [universal-tilt.js](https://npm.io/package/universal-tilt.js.md) ^2.0.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2019-07-28
- 1.3.0-beta.2 (beta) — 2019-03-23
- 1.2.0-beta.2 (next) — 2019-01-18
- 1.3.0 — 2019-03-30
- 1.3.0-beta.1 — 2019-03-23
- 1.2.0 — 2019-03-05
- 1.2.0-beta.1 — 2018-12-10
- 1.1.4 — 2018-11-12
- 1.1.3 — 2018-11-11
- 1.1.3-beta.1 — 2018-11-10
- 1.1.2 — 2018-11-01
- 1.1.1 — 2018-10-21
- 1.1.0 — 2018-10-21
- 1.0.10 — 2018-10-03
- 1.0.9 — 2018-09-30
- … 10 more at https://npm.io/package/react-universal-tilt/versions

## README

# [react-universal-tilt](https://github.com/jb1905/react-universal-tilt)

[![NPM version](http://img.shields.io/npm/v/react-universal-tilt.svg?style=flat-square)](https://www.npmjs.com/package/react-universal-tilt)
[![NPM downloads](http://img.shields.io/npm/dm/react-universal-tilt.svg?style=flat-square)](https://www.npmjs.com/package/react-universal-tilt)

#### [universal-tilt.js](https://www.npmjs.com/package/universal-tilt.js) implementation for React component
## Demo
**[See plugin in action](https://jb1905.github.io/universal-tilt.js/)**

## How to Use
First, install the library in your project by npm:
```sh
$ npm install react-universal-tilt
```

Or Yarn:
```sh
$ yarn add react-universal-tilt
```

## Getting Started
**• Import plugin in React application file:**
```js
import ReactTilt from 'react-universal-tilt';
```

**• Later create parallax component and pass options:**
```js
<ReactTilt
  settings={ /* settings */ }
  callbacks={ /* callbacks */ }
  className={ /* class name(s) */ }
  tiltChange={ /* event output destination */ }
  // other props for div tag e.g. style
/>
```

You can add components with or without additional content:

*with:*
```js
<ReactTilt /* options */>
  // additional content
</ReactTilt>
```
*without:*
```js
<ReactTilt /* options */ />
```

## Props
Name | Type | Default | Description | Available options
-|-|-|-|-
**settings** | object | `{}` | [Default universal-tilt.js settings](https://github.com/JB1905/universal-tilt.js#settings) | [universal-tilt.js settings](https://github.com/JB1905/universal-tilt.js#settings)
**callbacks** | object | `{}` | [Default universal-tilt.js callbacks](https://github.com/JB1905/universal-tilt.js#callbacks) | [universal-tilt.js settings](https://github.com/JB1905/universal-tilt.js#callbacks)
**className** | string | `tilt` | Tilt element class name | Name of tilt element

## Event
`tiltChange` event will output the x, y & angle of tilting

## Examples
```js
import React, { Component } from 'react';
import ReactTilt from 'react-universal-tilt';

/* ------ First Example ------ */

export class FirstExample extends Component {
  render() {
    return (
      <ReactTilt
        settings={{
          base: 'window',
          reverse: true
        }}

        style={{
          'border': '1px solid #333'
        }}

        className="tilt-elem my-tilt"
      />
    );
  }
}

/* ------ Second Example ------ */

function myFunc(el) {
  el.style.backgroundColor = '#f00';
}

export class SecondExample extends Component {
  output(e) {
    console.log(e.tiltX, e.tiltY, e.angle);
  }

  render() {
    const style = {
      'border': '1px solid #333'
    };

    return (
      <ReactTilt
        settings={{
          speed: 500,
          scale: 1.3
        }}

        callbacks={{
          onMouseMove: el => myFunc(el)
        }}

        style={style}

        className="tilt-elem my-tilt"

        tiltChange={this.output}
      >
        <h3>Hello World!</h3>
      </ReactTilt>
    );
  }
}
```

## License
This project is licensed under the MIT License © 2018-present Jakub Biesiada

---
_Source: https://npm.io/package/react-universal-tilt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
