👓 Parallax tilt hover effect for React JS - tilt.js

Overview

React.js - Tilt.js

Travis CI

react-tilt demo gif

React version of tilt.js

Demo

https://vx-demo.now.sh/gallery

Install

  • yarn: yarn add react-tilt
  • npm: npm install --save react-tilt

Usage

import Tilt from 'react-tilt'

<Tilt className="Tilt" options={{ max : 25 }} style={{ height: 250, width: 250 }} >
 <div className="Tilt-inner"> 👽 </div>
</Tilt>

Options

{
	reverse:        false,  // reverse the tilt direction
	max:            35,     // max tilt rotation (degrees)
	perspective:    1000,   // Transform perspective, the lower the more extreme the tilt gets.
	scale:          1.1,      // 2 = 200%, 1.5 = 150%, etc..
	speed:          1000,    // Speed of the enter/exit transition
	transition:     true,   // Set a transition on enter/exit.
	axis:           null,   // What axis should be disabled. Can be X or Y.
	reset:          true    // If the tilt effect has to be reset on exit.
	easing:         "cubic-bezier(.03,.98,.52,.99)",    // Easing on enter/exit.
}

API

Property Signature
onMouseEnter () -> SyntheticEvent
onMouseMove () -> SyntheticEvent
onMouseLeave () -> SyntheticEvent
options Object

Roadmap

  • Tests
  • Add Flare effect

Alternatives

Comments
  • Something strange happens with scrolling

    Something strange happens with scrolling

    In the demo: https://vx-demo.now.sh/gallery

    try scrolling down while trying to keep the mouse over the tilt element.

    You will see how the tilting get's stuck on one of the sides.

    I'm going to try to use the basic library. But thought I'd let you know.

    opened by bernatfortet 3
  • Component throws on unmount

    Component throws on unmount

    Hi,

    very nice tilt component, works very well! I guess there is a problem while unmounting Tilt. It is possible that some of the delayed executions (via setTimeout/requestAnimationFrame) will be executed after the component is unmounted, which will result in a React warning caused by setState calls.

    Something like

    Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the Tilt component.
    

    I was able to solve this problem by adding some tear down logic:

    componentWillUnmount() {
       clearTimeout(this.transitionTimeout);
       cancelAnimationFrame(this.updateCall);
    }
    

    Should I prepare a PR?

    Thanks!

    opened by otbe 2
  • Options don't work.

    Options don't work.

    I assume this is abandoned..

    But yeah, the options don't work at all. Only the styles do. I get the tilt effect using the basic setup, but any option I change makes no difference to the default 🤷🏽‍♂️

    opened by tr1s 1
  • Update package.json to include the repository

    Update package.json to include the repository

    NOTE: This is not a bot. This change was made by and comments will be reviewed by humans. We are using this service account to be able to track the overall progress.

    With the rise in supply chain attacks and OSS dependencies being used as a attack vector, Microsoft is working with our ecosystem partners, such as the Linux Foundation's OpenSSF, to enable OSS consumers to track packages back to their public sources.

    We've identified that the following packages published to NPM do not report where sources can be found, typically accomplished by including a link to your GitHub repository in your package.json REPOSITORY field. This PR was created to add this value, ensuring future releases will include this provenance information.

    If you do not want us to create such PRs against your GitHub repositories, or wish to provide any other feedback, please comment on this PR.

    Published NPM packages with repository information: • react-tilt

    opened by msftenhanceprovenance 3
  • Support react 17

    Support react 17

    The project needs to update its dependencies to also support react 17. The current code seems to work with react 17, so it should just be a change in the package.json.

    opened by andreasjacobsen93 2
  • added new origin factor feature

    added new origin factor feature

    origin factor feature

    Had an idea for adding a customisable origin factor feature.

    the idea is very simple, by default, the tilt origin is from center, I needed a different origin, maybe from bottom, or the left side or maybe somewhere between center and top, so I created a solution for this problem. I added two options: XOrigin (default 0) and YOrigin (default 0). the range for both is from -1 to 1, -1 is the very start of the axis and 1 is the end of the axis, of course the default (0) is the center of the axis. usage:

    <Tilt options={{ XOrigin: -1, YOrigin: -1 }}>
        this origin will be from top left corner
    </Tilt>
    

    (by the way i dont now how to delete the package-lock.json file from the commits so you can just delete it)

    opened by itaysmalia 0
Recreation of the background scale hover effect seen on the DDD Hotel website using CSS clip paths.

Background Scale Hover Effect Recreation of the background scale hover effect seen on the DDD Hotel menu using CSS clip paths. Article on Codrops Demo

Codrops 98 Dec 6, 2022
A motion hover effect for a background grid of images.

Image Grid Motion Effect A motion hover effect for a background grid of images. Article on Codrops Demo Installation Install dependencies: npm install

Codrops 118 Dec 31, 2022
Demos for the tutorial on how to achieve an interactive mouseover/hover effect

Interactive Hover Effects with Three.js A simple tutorial on how to achieve an interactive mouseover/hover effect on images in some easy steps. Articl

Yuri Artiukh 246 Dec 27, 2022
magneticHover lets you trigger hover effect on the element when the cursor is near it, but not over it yet

magneticHover magneticHover lets you trigger hover effect on the element when the cursor is near it, but not over it yet. Examples https://codesandbox

Halo Lab 35 Nov 30, 2022
Simple jQuery plugin for 3d Hover effect

jQuery Hover3d jQuery Hover3d is a simple hover script for creating 3d hover effect. It was my experiment on exploring CSS3 3d transform back in 2015

Rian Ariona 333 Jan 4, 2023
Pure CSS Image Hover Effect Library

imagehover.css A Scaleable & Light Image Hover CSS Library Imagehover.css is a lovingly crafted CSS library allowing you to easily implement scaleable

Ciaran Walsh 1.8k Dec 21, 2022
A set of buttons with a magnetic interaction and a hover effect.

Magnetic Buttons A small set of magnetic buttons with some fun hover animations. Inspired by the button animation seen on Cuberto. Article on Codrops

Codrops 405 Dec 24, 2022
Demo of the tutorial on how to craft a fullscreen SVG crosshair mouse cursor with a special distortion effect on hover.

Crosshair Mouse Cursor Distortion Demo of the tutorial on how to craft a fullscreen SVG crosshair mouse cursor with a special distortion effect on hov

Codrops 33 Sep 23, 2022
Liquideffect - Javascript Library for creating liquid effect on image and RGB effect on mouse direction.

LiquidEffect Javascript Library for creating liquid effect on image and RGB effect on mouse direction. Demo https://liquideffect.netlify.app/ Dependen

Rohail 8 May 6, 2022
Some shape morphing hover effects on images using SVG clipPath.

Organic Shape Animations with SVG clipPath Some shape morphing hover effects using SVG clipPath on an image. Article on Codrops Demo Credits Anime.js

Codrops 197 Oct 16, 2022
Javascript library to draw and animate images on hover

Hover effect Javascript library to draw and animate images on hover. If this project help you, you like this library or you just want to thank me, you

Robin Delaporte 1.5k Dec 23, 2022
A mouse particle effect react component

react-mouse-particles A mouse particle effect react component A very fun react library that can be used to create mouse particle effects, which are as

lindelof 92 Dec 17, 2022
KenBurns Image Effect for React Native Applications

react-native-kenburns-view KenBurns Image Effect for React Native. Based on Image Component Image Component. Version: 4.1.0 Tested on React Native 0.6

Nimila Hiranya Samarasinghe 58 Sep 3, 2022
A Snow Effect component for React.

react-snowstorm A Snow Effect component for React. Uses Snowstorm under the hood. Live Demo : http://burakcan.github.io/react-snowstorm Getting Starte

Burak Can 225 Aug 31, 2022
Add a water ripple effect to your background using WebGL.

jQuery Ripples Plugin By the powers of WebGL, add a layer of water to your HTML elements which will ripple by cursor interaction! Important: this plug

Pim Schreurs 976 Dec 30, 2022
A decorative website background effect where SVG shapes morph and transform on scroll.

Morphing Background Shapes A decorative website background effect where SVG shapes morph and transform on scroll. Article on Codrops Demo This demo is

Codrops 351 Dec 26, 2022
Background image segment effect as seen on [Filippo Bello's Portfolio](http://www.filippobello.com/portfolio).

Segment Effect Background image segment effect as seen on Filippo Bello's Portfolio. Article on Codrops Demo License Integrate or build upon it for fr

Codrops 526 Nov 29, 2022
Switch the background-image with using effect.

jQuery.BgSwitcher Switch the background image with using effect. Demo http://rewish.github.io/jquery-bgswitcher/ Usage <div class="box"> <p>Lorem ip

rewish 195 Dec 30, 2022
fixed-background-effect

Fixed Background Effect A simple template that takes advantage of the background-attachment CSS property to create a fixed background effect. Article

CodyHouse 50 Oct 28, 2022