Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple elements in mouse-event -elements #81

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bff29e6
Changed folder structure
Jan 29, 2017
c282337
Changed folder structure
Jan 29, 2017
427af8a
Added responsive design and fixed typo
Jan 29, 2017
ebab388
Merge pull request #3 from bastilimbach/gh-pages
micku7zu Jan 29, 2017
8583d68
Fix download links.
micku7zu Jan 29, 2017
80081cf
Fix twitter ugly scrollbar on Chrome
micku7zu Jan 29, 2017
602bca8
Added credits on the mobile version
Jan 29, 2017
69cb6f2
Merge pull request #5 from bastilimbach/gh-pages
micku7zu Jan 29, 2017
fac3f50
Fixed typo
pborreli Jan 30, 2017
8489def
Merge pull request #6 from pborreli/patch-1
micku7zu Jan 30, 2017
6d64075
Change library location
micku7zu Jan 30, 2017
c5cc3a8
Merge branch 'gh-pages' of https://github.com/micku7zu/vanilla-tilt.j…
micku7zu Jan 30, 2017
8354dd5
Fix .gitignore and logo margin
micku7zu Jan 30, 2017
cfc4f38
Add reverse demo
micku7zu Jan 30, 2017
31e90bc
iOS scroll fix
micku7zu Jan 31, 2017
93d6713
Fix twitter share link
micku7zu Feb 3, 2017
f8d6058
Add npm instructions
micku7zu Feb 23, 2017
9fbadff
Add glare example
SergiuSandorPPB Jun 13, 2017
32cc7b0
Update tilt event example code
micku7zu Jul 7, 2017
1a2fdde
Update version to 1.5.0
micku7zu Oct 17, 2018
a6ddc41
Update README.md
micku7zu Dec 14, 2018
002fb43
Update index.html
micku7zu Dec 14, 2018
744a7de
Update parallax effect docs
micku7zu Dec 14, 2018
a1159be
Add device orientation support
micku7zu Dec 22, 2018
6b75af5
Add contributors on readme and on demo page
micku7zu Dec 22, 2018
833340c
Add contributors on mobile demo page
micku7zu Dec 22, 2018
b8963a0
Fix scroll x on mobile
micku7zu Dec 22, 2018
632585c
Fix scroll x on mobile
micku7zu Dec 22, 2018
8a89159
Update library to 1.6.1
micku7zu Dec 28, 2018
fe18dba
Update to version 1.6.2
micku7zu Apr 12, 2019
17e7669
Update contributors
micku7zu Apr 12, 2019
85f4d2c
Update to version 1.6.3. Refactored some code and fixed degrees calcu…
micku7zu Apr 13, 2019
fcad3a2
Update to version 1.7.0 Refactored some code after many pull requests.
micku7zu Apr 13, 2019
03a9232
Missing semicolons (#75)
k-tten Mar 29, 2021
6d10d0e
Fix vanilla-tilt.js logo
micku7zu Apr 19, 2021
815bd34
Update to 1.7.1
micku7zu Jul 28, 2021
1590a44
Add other projects section
micku7zu Jan 11, 2022
0a57570
typo on examples page and in README.md (#104)
SherylHohman Feb 20, 2022
c1c0359
typos: in docs for options object (#105)
SherylHohman Feb 20, 2022
9f71382
typo: delete errant line in options object docs (#106)
SherylHohman Feb 21, 2022
c079672
Update README.md
micku7zu Oct 27, 2022
7618f4e
Update index.html
micku7zu Oct 27, 2022
e230549
Update README.md
micku7zu Dec 12, 2022
c68bc41
Update to version 1.8.0
micku7zu Dec 12, 2022
a2cd28f
Fix destroy method and update to version 1.8.1
micku7zu Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
lib
.idea
.tern-port
91 changes: 74 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
# vanilla-tilt.js

[![npm version](https://badge.fury.io/js/vanilla-tilt.svg)](https://badge.fury.io/js/vanilla-tilt)

A smooth 3D tilt javascript library forked from [Tilt.js (jQuery version)](https://github.com/gijsroge/tilt.js).

[View landing page (demos)](https://micku7zu.github.io/vanilla-tilt.js/landing/index.html)
[View landing page (demos)](https://micku7zu.github.io/vanilla-tilt.js/)

### Usage

```html
<body>

<!-- your markup element -->
<div class="your-element" data-tilt></div>

<!-- at the end of the body -->
<script type="text/javascript" src="vanilla-tilt.js"></script>
</body>
```

If you want to use this library in IE, you need to include a CustomEvent polyfill: https://github.com/micku7zu/vanilla-tilt.js/issues/49#issuecomment-482711876 or maybe consider the [jQuery version](https://github.com/gijsroge/tilt.js).
### Options
```js
{
max: 35, // max tilt rotation (degrees)
perspective: 1000, // Transform perspective, the lower the more extreme the tilt gets.
scale: 1, // 2 = 200%, 1.5 = 150%, etc..
speed: 300, // Speed of the enter/exit transition
transition: true, // Set a transition on enter/exit.
axis: null, // What axis should be disabled. Can be X or Y.
reset: true // If the tilt effect has to be reset on exit.
easing: "cubic-bezier(.03,.98,.52,.99)", // Easing on enter/exit.
reverse: false, // reverse the tilt direction
max: 15, // max tilt rotation (degrees)
startX: 0, // the starting tilt on the X axis, in degrees.
startY: 0, // the starting tilt on the Y axis, in degrees.
perspective: 1000, // Transform perspective, the lower the more extreme the tilt gets.
scale: 1, // 2 = 200%, 1.5 = 150%, etc..
speed: 300, // Speed of the enter/exit transition
transition: true, // Set a transition on enter/exit.
axis: null, // What axis should be enabled. Can be "x" or "y".
reset: true, // If the tilt effect has to be reset on exit.
"reset-to-start": true, // Whether the exit reset will go to [0,0] (default) or [startX, startY]
easing: "cubic-bezier(.03,.98,.52,.99)", // Easing on enter/exit.
glare: false, // if it should have a "glare" effect
"max-glare": 1, // the maximum "glare" opacity (1 = 100%, 0.5 = 50%)
"glare-prerender": false, // false = VanillaTilt creates the glare elements for you, otherwise
// you need to add .js-tilt-glare>.js-tilt-glare-inner by yourself
"mouse-event-element": null, // css-selector or link to an HTML-element that will be listening to mouse events
"full-page-listening": false, // If true, parallax effect will listen to mouse move events on the whole document, not only the selected element
gyroscope: true, // Boolean to enable/disable device orientation detection,
gyroscopeMinAngleX: -45, // This is the bottom limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the left border of the element;
gyroscopeMaxAngleX: 45, // This is the top limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the right border of the element;
gyroscopeMinAngleY: -45, // This is the bottom limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the top border of the element;
gyroscopeMaxAngleY: 45, // This is the top limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the bottom border of the element;
gyroscopeSamples: 10 // How many gyroscope moves to decide the starting position.
}
```

### Events
```js
const element = document.querySelector(".js-tilt");
VanillaTilt.init(element);
element.addEventListeners("tiltChange", callback);
element.addEventListener("tiltChange", callback);
```

### Methods
Expand All @@ -48,26 +70,61 @@ element.vanillaTilt.getValues();

// Reset instance
element.vanillaTilt.reset();

// It also supports NodeList
const elements = document.querySelectorAll(".js-tilt");
VanillaTilt.init(elements);
```

### Install
You can copy and include any of the following file:

TO DO (automatically build those):
* [dist/vanilla-tilt.js](https://raw.githubusercontent.com/micku7zu/vanilla-tilt.js/master/dist/vanilla-tilt.js) ~ 15kb
* [dist/vanilla-tilt.min.js](https://raw.githubusercontent.com/micku7zu/vanilla-tilt.js/master/dist/vanilla-tilt.min.js) ~ 8.5kb
* [dist/vanilla-tilt.babel.js](https://raw.githubusercontent.com/micku7zu/vanilla-tilt.js/master/dist/vanilla-tilt.babel.js) ~ 16.5kb
* [dist/vanilla-tilt.babel.min.js](https://raw.githubusercontent.com/micku7zu/vanilla-tilt.js/master/dist/vanilla-tilt.babel.min.js) ~ 9.5kb

#### NPM

Also available on npm https://www.npmjs.com/package/vanilla-tilt

```
npm install vanilla-tilt
```

Import it using

* dest/vanilla-tilt.js ~ 6kb
* dest/vanilla-tilt.min.js ~ 3.5kb
* dest/vanilla-tilt.babel.js ~ 8.5kb
* dest/vanilla-tilt.babel.min.js ~ 4.3kb
```
import VanillaTilt from 'vanilla-tilt';
```

in your webiste.
### Known issues
- [Getting weird rendering issues on Safari](https://github.com/micku7zu/vanilla-tilt.js/issues/22)

### Credits

Original library: [Tilt.js](http://gijsroge.github.io/tilt.js/)

Original library author: [Gijs Rogé](https://twitter.com/GijsRoge)

#### Contributors

- [Livio Brunner](https://github.com/BrunnerLivio) <<a href="mailto:[email protected]">[email protected]</a>> (Typings & Glare Effect)
- [Oleg Postoev](https://github.com/Dok11)
- [Matteo Rigon](https://github.com/matteo-rigon) (Device orientation support)
- [Corey Austin](https://github.com/lazyhummingbird) (Initial gyroscope position)
- [Sander Moolin](https://github.com/SaFrMo)
- [rrroyal](https://github.com/rrroyal) (Whole document mouse events listening)
- [Andžs Pilskalns](https://github.com/Pilskalns) ("reset-to-start" feature)

### Other projects

#### [Quick Cursor: One-Handed mode](https://play.google.com/store/apps/details?id=com.quickcursor) (Android app)
Play Store link: https://play.google.com/store/apps/details?id=com.quickcursor

### Buy me a beer 🍻
If you want to thank me for vanilla-tilt.js or Quick Cursor Android app, you can [donate on PayPal](https://www.paypal.me/micku7zu?locale.x=en_US): https://www.paypal.me/micku7zu?locale.x=en_US

### License

MIT License
MIT License
227 changes: 0 additions & 227 deletions dest/vanilla-tilt.babel.js

This file was deleted.

Loading