1 | # paroller.js
|
2 |
|
3 | [![npm](https://img.shields.io/npm/v/paroller.js.svg)](https://www.npmjs.com/package/paroller.js)
|
4 |
|
5 | A lightweight jQuery plugin that enables parallax scrolling effect
|
6 | - You can use it on elements with background property or on any other element
|
7 | - While scrolling elements can move: vertical, horizontal
|
8 | - Manipulated through html data-* attributes or jQuery options
|
9 | - Mobile ready
|
10 | - Easy to use
|
11 |
|
12 | **DEMO:** [Example page](https://tgomilar.github.io/paroller.js/), [Alveus](https://alveus.si/en)
|
13 |
|
14 | ## Install
|
15 | Before closing ```</body>``` element include:
|
16 |
|
17 | 1. [jQuery](http://jquery.com/download/)
|
18 | 2. [jquery.paroller.js](https://github.com/tgomilar/paroller.js/tree/master/dist)
|
19 |
|
20 |
|
21 | #### npm
|
22 | ```sh
|
23 | $ npm install paroller.js
|
24 | ```
|
25 |
|
26 | #### Bower
|
27 | ```sh
|
28 | $ bower install paroller.js
|
29 | ```
|
30 | #### Yarn
|
31 | ```sh
|
32 | $ yarn add paroller.js
|
33 | ```
|
34 | ## Use
|
35 | ```javascript
|
36 | // initialize paroller.js
|
37 | $('.my-paroller').paroller();
|
38 | // initialize paroller.js and set attributes
|
39 | $("#my-element").paroller({ factor: '0.5', type: 'foreground', direction: 'horizontal' });
|
40 | ```
|
41 | ```html
|
42 | <!-- select element -->
|
43 | <div class="my-paroller" data-paroller-factor="0.3" data-paroller-type="foreground" data-paroller-direction="horizontal"></div>
|
44 | <div id="my-element"></div>
|
45 | ```
|
46 |
|
47 | **npm and browserify**
|
48 | ```sh
|
49 | require('paroller.js');
|
50 | ```
|
51 |
|
52 | ## Options
|
53 | ### data attributes
|
54 | You can control scrolling parallax effect by setting data-paroller-* values attributes or by setting JavaScript options.
|
55 |
|
56 | *data-paroller-factor* sets speed and distance of element's parallax effect on scroll.
|
57 |
|
58 |
|
59 | | data-* | value | default value |
|
60 | | ------ | ------ | ------ |
|
61 | | data-paroller-factor | sets offset and speed. It can be positive (0.3) or negative (-0.3). Less means slower. | 0 |
|
62 | | data-paroller-type | background, foreground | background |
|
63 | | data-paroller-direction | vertical, horizontal | vertical |
|
64 |
|
65 | ### JavaScript
|
66 | ```javascript
|
67 | // initialize paroller.js and set attributes for selected elements
|
68 | $(".paroller, [data-paroller-factor]").paroller({
|
69 | factor: 0.3, // multiplier for scrolling speed and offset, +- values for direction control
|
70 | type: 'foreground', // background, foreground
|
71 | direction: 'horizontal' // vertical, horizontal
|
72 | });
|
73 |
|
74 | ```
|
75 |
|
76 | License
|
77 | ----
|
78 |
|
79 | MIT
|
80 |
|