vanilla-tilt.js

A smooth 3D tilt javascript library forked from Tilt.js (jQuery version).
View landing page (demos)
Usage
<body>
<div class="your-element" data-tilt></div>
<script type="text/javascript" src="vanilla-tilt.js"></script>
</body>
If you want to use this library in IE, you need to include a CustomEvent polyfill: https://github.com/micku7zu/vanilla-tilt.js/issues/49#issuecomment-482711876 or maybe consider the jQuery version.
Options
{
reverse: false,
max: 15,
startX: 0,
startY: 0,
perspective: 1000,
scale: 1,
speed: 300,
transition: true,
axis: null,
reset: true,
"reset-to-start": true,
easing: "cubic-bezier(.03,.98,.52,.99)",
glare: false,
"max-glare": 1,
"glare-prerender": false,
"mouse-event-element": null,
"full-page-listening": false,
gyroscope: true,
gyroscopeMinAngleX: -45,
gyroscopeMaxAngleX: 45,
gyroscopeMinAngleY: -45,
gyroscopeMaxAngleY: 45,
gyroscopeSamples: 10
}
Events
const element = document.querySelector(".js-tilt");
VanillaTilt.init(element);
element.addEventListener("tiltChange", callback);
Methods
const element = document.querySelector(".js-tilt");
VanillaTilt.init(element);
element.vanillaTilt.destroy();
element.vanillaTilt.getValues();
element.vanillaTilt.reset();
const elements = document.querySelectorAll(".js-tilt");
VanillaTilt.init(elements);
Install
You can copy and include any of the following file:
NPM
Also available on npm https://www.npmjs.com/package/vanilla-tilt
npm install vanilla-tilt
Import it using
import VanillaTilt from 'vanilla-tilt';
Known issues
Credits
Original library: Tilt.js
Original library author: Gijs Rogé
Contributors
Other projects
Play Store link: https://play.google.com/store/apps/details?id=com.quickcursor
Buy me a beer 🍻
If you want to thank me for vanilla-tilt.js or Quick Cursor Android app, you can donate on PayPal: https://www.paypal.me/micku7zu?locale.x=en_US
License
MIT License