Interactive Parallax Tilt Effect In Vanilla JavaScript – vanilla-tilt.js

Category: Animation , Javascript , Recommended | January 29, 2017
Author: micku7zu
Views Total: 1,030
Official Page: Go to website
Last Update: January 29, 2017
License: MIT

Preview:

Interactive Parallax Tilt Effect In Vanilla JavaScript – vanilla-tilt.js

Description:

vanilla-tilt.js is a lightweight JavaScript library for creating interactive parallax tilt effect on DOM element using requestAnimationFrame. Similar to the Apple tvOS’ poster parallax effect. Without any dependencies and fully customizable.

How to use it:

Download and place the main JavaScript file vanilla-tilt.js at the bottom of the webpage.

<script src="vanilla-tilt.js"></script>

Apply the parallax tilt effect to your element using HTML data attribute as follow:

<div data-tilt></div>

Or initialize the parallax tilt effect with the following configuration options.

VanillaTilt.init(document.querySelectorAll(".element"), {
  max: 20,
  perspective: 1000,
  easing: "cubic-bezier(.03,.98,.52,.99)",
  scale: "1",
  speed: "300",
  transition: true,
  axis: null,
  reset: true
});

API methods.

// Destroy
element.vanillaTilt.destroy();

// Get values
element.vanillaTilt.getValues();

// Reset
element.vanillaTilt.reset();