The most basic usage:
- Add
<script src="tilt.jquery.js"></script>
right before the closing</body>
tag - Mark your elements with
<span data-tilt></span>
A tiny requestAnimationFrame powered 60+fps
lightweight parallax hover tilt effect for jQuery.
yarn add tilt.js
or download<script src="tilt.jquery.js"></script>
right before the closing </body>
tag
<span data-tilt></span>
transform-style: preserve-3d
to your tilt element.transform: translateZ(20px)
to your inner elements that have to pop out.Setting this option will enable a glare effect. You can tweak the glare value with {'maxGlare': .5}
$('.js-tilt').tilt({
glare: true,
maxGlare: .5
})
Setting this option will not reset the tilt element when the user mouse leaves the element.
$('.js-tilt').tilt({
reset: false
})
Setting this option will scale tilt element on hover.
$('.js-tilt').tilt({
scale: 1.2
})
Setting this option will disable the Y-Axis on the tilt element.
$('.js-tilt').tilt({
axis: x
})
Setting this option will disable the X-Axis on the tilt element.
$('.js-tilt').tilt({
axis: y
})
Call this method will remove all events and classes from the tilt element.
const tilt = $('.js-tilt').tilt()
tilt.methods.destroy.call(tilt);
The on change event wil output the x,y & percentages of tilting.
const tilt = $('.js-tilt').tilt()
tilt.on('change', function(e, transforms){});
Options can be passed with thetilt()
function.
$('.js-tilt').tilt({
option: value,
option: value,
});
All options are configurable trough data-attributes.
data-tilt-<option name>="value"