Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
329
decreased by-20.34%
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), new Position Base option and more!

Demo

See plugin in action

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
resetbooleantrueEnable/disable element position reset after mouseouttrue (enable), false (disable)
mobilebooleantrueEnable/disable tilt effect on mobile devicestrue (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

License

This project is licensed under the MIT License

Keywords

FAQs

Package last updated on 14 Apr 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