31 |
32 |
33 |
41 |
42 |
43 |
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # vanilla-tilt-vue
5 |
6 |
7 |
8 |
9 |
10 | ## Installation
11 |
12 |
13 |
14 | `npm i vanilla-tilt-vue`
15 |
16 |
17 |
18 |
19 |
20 | ## Usage
21 |
22 |
23 |
24 | ```js
25 |
26 | Import Tilt from 'vanilla-tilt-vue'
27 |
28 | ```
29 |
30 | And inside your template...
31 |
32 | ```html
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | ```
45 |
46 | The options prop must be a JavaScript object. The options available are identical to the ones required by vanilla-tilt
47 |
48 |
49 |
50 | ```js
51 |
52 | {
53 |
54 | reverse: false, // reverse the tilt direction
55 |
56 | max: 35, // max tilt rotation (degrees)
57 |
58 | startX: 0, // the starting tilt on the X axis, in degrees.
59 |
60 | startY: 0, // the starting tilt on the Y axis, in degrees.
61 |
62 | perspective: 1000, // Transform perspective, the lower the more extreme the tilt gets.
63 |
64 | scale: 1, // 2 = 200%, 1.5 = 150%, etc..
65 |
66 | speed: 300, // Speed of the enter/exit transition
67 |
68 | transition: true, // Set a transition on enter/exit.
69 |
70 | axis: null, // What axis should be disabled. Can be X or Y.
71 |
72 | reset: true, // If the tilt effect has to be reset on exit.
73 |
74 | easing: "cubic-bezier(.03,.98,.52,.99)", // Easing on enter/exit.
75 |
76 | glare: false, // if it should have a "glare" effect
77 |
78 | "max-glare": 1, // the maximum "glare" opacity (1 = 100%, 0.5 = 50%)
79 |
80 | "glare-prerender": false, // false = VanillaTilt creates the glare elements for you, otherwise
81 |
82 | // you need to add .js-tilt-glare>.js-tilt-glare-inner by yourself
83 |
84 | "mouse-event-element": null, // css-selector or link to HTML-element what will be listen mouse events
85 |
86 | // you need to add .js-tilt-glare>.js-tilt-glare-inner by yourself
87 |
88 | gyroscope: true, // Boolean to enable/disable device orientation detection,
89 |
90 | 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;
91 |
92 | 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;
93 |
94 | 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;
95 |
96 | 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;
97 |
98 | }
99 |
100 | ```
101 | To enable the parallax effect simply use
102 | ```html
103 |
104 |
105 | Your content here
106 |
107 |
108 | ```
109 | And add the CSS property `transform: translateZ(20px)` to the element that you want to float.
--------------------------------------------------------------------------------