Socket
Socket
Sign inDemoInstall

universal-tilt.js

Package Overview
Dependencies
0
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    universal-tilt.js

Parallax tilt effect library


Version published
Weekly downloads
571
increased by5.55%
Maintainers
1
Install size
82.2 kB
Created
Weekly downloads
 

Readme

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.js plugin

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

How to Install

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:

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

Getting Started

If you added library via package manager use 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)
mobilebooleantrueEnable/disable tilt effect on mobile devices with gyroscope (tilt effect on touch is always enabled)true (enable), 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 }
onDeviceMove2functionnullCall function on device moveel => { // code }

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

Event

tiltChange event will output the x & y of tilting

License

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

Keywords

FAQs

Last updated on 15 Jul 2018

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc