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

JavaScript & jQuery parallax tilt effect


Version published
Weekly downloads
387
decreased by-16.23%
Maintainers
1
Weekly downloads
 
Created
Source

universal-tilt.js

JavaScript & jQuery elements movement plugin based on:

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

universal-tilt.js contains additional functions for mobile devices (having a gyroscope) and new Position Base option

Usage

At the beginning connect the library with Your project:

• using script tag in HTML:

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

• or via command line and CommonJS/ES6 import:

npm install universal-tilt.js // npm
yarn add universal-tilt.js // yarn
const UniversalTilt = require('universal-tilt.js'); // CommonJS
import UniversalTilt form 'universal-tilt.js'; // ES6

Next use library with:

• Vanilla JavaScript e.g:

const tilts = document.querySelectorAll('.tilt');
const liveTilt = new UniversalTilt(tilts, {
   // 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 // npm
yarn add jquery // yarn
bower install jquery // bower
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
resetbooleantrueAllow/disable element position reset after mouseouttrue (allow), false (disable)
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.
onMouseEnterfunctionnullCall function on mouse enterel => { // code }
onMouseMovefunctionnullCall function on mouse moveel => { // code }
onMouseLeavefunctionnullCall function on mouse leaveel => { // code }
onDeviceMovefunctionnullCall function on device moveel => { // code }

1 shine value must be true

License

This project is licensed under the MIT License

Keywords

FAQs

Package last updated on 29 Mar 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