Socket
Socket
Sign inDemoInstall

universal-tilt.js

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-tilt.js

Parallax tilt effect library


Version published
Maintainers
1
Created
Source

universal-tilt.js

NPM version NPM downloads

JavaScript & jQuery elements movement library based on:

Tilt.js by Gijs Rogé and vanilla-tilt.js by Șandor Sergiu

universal-tilt.js contains additional functions for mobile devices with gyroscope, new Position Base option and more!

Demo

See plugin in action

React plugin

If You use React, install component, with the implementation of the universal-tilt.js library! More here

How to Install

At the beginning install the library in Your project via npm or Yarn:

$ npm install universal-tilt.js
$ yarn add universal-tilt.js

Getting Started

Connect using script tag in HTML:

<script src="/directory/to/library/folder/universal-tilt.js"></script>

Or CommonJS/ES6 import:

const UniversalTilt = require('universal-tilt.js'); // CommonJS
import UniversalTilt from 'universal-tilt.js'; // ES6

Next use library with:

• Vanilla JavaScript e.g:

const elems = document.querySelectorAll('.tilt');
const universalTilt = new UniversalTilt(elems, {
  // options...
});

• or jQuery e.g:

Connect jQuery in HTML

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

or include via command line and CommonJS

$ npm install jquery
$ yarn add jquery
$ bower install jquery
const jQuery = require('jquery');

and call plugin on element

$('.tilt').universalTilt({
  // options...
});

• Plugin supports autoinit

To use it, add data-tilt to html element e.g:

<div data-tilt></div>

Options

NameTypeDefaultDescriptionAvailable options
position-basestringelementThe surface from which the location of the mouse is capturedelement or window
resetbooleantrueEnable/disable element position reset after mouseouttrue (enable), false (disable)
excludeRegExpnullDisable tilt effect on selected user agentse.g: /(Mozilla|iPad)/
shinebooleanfalseAdd/remove shine effect on mouseovertrue (add), false (remove)
shine-opacity1number0Add/remove shine effect on mouseovervalues >= 0 and <= 1
shine-save1booleanfalseSave/reset shine effect on mouseouttrue (save), false (reset)
maxnumber35Max tilt valuee.g: 28
perspectivenumber1000Tilt effect perspectivee.g: 700
scalenumber1.0Element scale on mouseover0.9/1.3/etc.
disabledstringnullDisable axisx or y
reversebooleanfalseReverse tilt effect directorytrue (reverse directory), false (standard directory)
speednumber300Transition speed (ms)e.g: 500
easingstringcubic-bezier(.03, .98, .52, .99)Transition easingcubic-bezier/ease/linear/etc.
onMouseEnterfunctionnullCallback on mouse enterel => { // code }
onMouseMovefunctionnullCallback on mouse moveel => { // code }
onMouseLeavefunctionnullCallback on mouse leaveel => { // code }
onDeviceMove2functionnullCallback on device moveel => { // code }

1 shine value must be true
2 mobile value must be true

Event

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

License

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

Keywords

FAQs

Package last updated on 15 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc