You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
simpleParallax.js is a very simple and tiny Vanilla JS library that adds parallax animations on any images.
7
+
simpleParallax.js is a lightweight and easy-to-use React and JS library that adds parallax animations to any image.
8
8
9
-
Where it may be laborious to get results through other plugins, simpleParallax.js stands out for its ease and its visual rendering. The parallax effect is directly applied to image tags, there is no need to use background images. More info on the case study [here](https://medium.com/@geoffrey.signorato/case-study-create-a-parallax-effect-directly-on-img-tags-with-javascript-35b8daf81471).
10
-
11
-
Any image will fit. Try it out!
9
+
While other plugins can be complex, simpleParallax.js is notable for its simplicity and impressive visual effects. The parallax effect is applied directly to image tags, eliminating the need for background images. Any image can be used. More info on the case study [here](https://medium.com/@geoffrey.signorato/case-study-create-a-parallax-effect-directly-on-img-tags-with-javascript-35b8daf81471).
12
10
11
+
Give it a try!
13
12
14
13
## Installation
15
14
16
-
### Old way
17
-
18
-
Simply copy/paste the below snippet just before your closing `</body>` tag :
19
-
20
-
```html
21
-
<scriptsrc="simpleParallax.js"></script>
22
-
```
23
-
24
-
or use the below CDN link provided by [jsDelivr.com](https://www.jsdelivr.com/package/npm/simple-parallax-js) :
You can also choose to apply the parallax on multiple images :
72
68
73
69
```javascript
@@ -99,12 +95,51 @@ scale | Number | 1.3 | need to be above 1
99
95
overflow | Boolean | false |
100
96
delay | Number | 0 | the delay is in second **Watch out, sometimes this delay is causing issue on iOS devices [#47](https://github.com/geosigno/simpleParallax.js/issues/47)**
101
97
transition | String | '' | any CSS transition
102
-
customContainer | String or Node | '' |
103
-
customWrapper | String | '' | the selector of the custom wrapper
104
98
maxTransition | Number | 0 | it should be a percentage between 1 and 99
99
+
customContainer | String or Node | '' | (Vanilla version only)
100
+
customWrapper | String | '' | the selector of the custom wrapper (Vanilla version only)
105
101
106
102
You can apply these settings with the following JS code :
var images =document.querySelectorAll('.thumbnail');
110
145
newsimpleParallax(images, {
@@ -118,28 +153,31 @@ new simpleParallax(images, {
118
153
```
119
154
120
155
### orientation - *String* - see [example](https://simpleparallax.com#example-orientation)
121
-
This is the orientation (or direction) of the parallax effect. Choose *up* and when scrolling down, the image will translate from the bottom to the top (so the image will translate up). When scrolling up, the image will translate from the top to the bottom. Same logic applies for all others orientations (*right*, *down*, *left*, *up left*, *up right*, *down left* or*down right*). When 2 directions are combined (for example*down right*), the image will translate diagonally.
156
+
The parallax effect's orientation, or direction, can be customized. If you choose *up*, the image will move from bottom to top as you scroll down, and from top to bottom as you scroll up. This same logic applies for all other orientations, including *right*, *down*, *left*, *up left*, *up right*, *down left*, and*down right*. If two directions are combined, such as*down right*, the image will move diagonally.
122
157
123
158
### scale - *Number* - see [example](https://simpleparallax.com#example-scale)
124
-
The higher the scale is set, the more visible the parallax effect will be. In return, the image will lose in quality. To reduce the lossless effect, if the scale is set at 1.5 and your image is 500px width, do the simple math 500 * 1.5 = 750. So you can choose a 750px image to replace your 500px one, and don't see any quality leak. More information is available if you read the case study [here](https://medium.com/@geoffrey.signorato/case-study-create-a-parallax-effect-directly-on-img-tags-with-javascript-35b8daf81471).
159
+
The higher the *scale* setting, the more pronounced the parallax effect becomes. However, this can cause the image quality to diminish. To mitigate this, if the *scale* is set at 1.5 and your image width is 500px, simply multiply 500 by 1.5 to get 750. You can then use a 750px image in place of your 500px one to maintain image quality. More information can be found in the case study linked[here](https://medium.com/@geoffrey.signorato/case-study-create-a-parallax-effect-directly-on-img-tags-with-javascript-35b8daf81471).
125
160
126
161
### overflow - *Boolean* - see [example](https://simpleparallax.com#example-overflow)
127
-
By default, the image is scaled to apply a parallax effect without any overflow on the layout - you can check the [case study](https://medium.com/@geoffrey.signorato/case-study-create-a-parallax-effect-directly-on-img-tags-with-javascript-35b8daf81471) to have a better understanding. When *overflow* is set to true, the image will translate out of its natural flow (so it may overlap with your content).
162
+
By default, the image scales to create a parallax effect without any overflow on the layout - for a better understanding, review the [case study](https://medium.com/@geoffrey.signorato/case-study-create-a-parallax-effect-directly-on-img-tags-with-javascript-35b8daf81471). When overflow is set to true, the image will translate beyond its natural flow, potentially overlapping your content.
128
163
129
164
### delay - *Number* - see [example](https://simpleparallax.com#example-delay-transition)
130
-
When a *delay* is set, the translation of the image will continue during that delay when the user stops scrolling. That gives a very nice effect. The delay is in second. **Watch out, sometimes this delay is causing issue on iOS devices [#47](https://github.com/geosigno/simpleParallax.js/issues/47)**
165
+
Setting a delay prolongs the image's translation even after the user has stopped scrolling, creating a pleasing effect. This delay is measured in seconds. **Watch out, sometimes this delay is causing issue on iOS devices [#47](https://github.com/geosigno/simpleParallax.js/issues/47)**
131
166
132
167
### transition - *String* - see [example](https://simpleparallax.com#example-delay-transition)
133
-
The *transition* setting works closely with the *delay* setting. This setting will add any CSS transition to the delay setting. For example, you can use *ease* or *ease-in-out*.
168
+
The transition setting is linked with the delay setting. It applies any CSS transition to the delay setting, such as ease or ease-in-out.
169
+
170
+
### maxTransition - *Number* - see [example](https://simpleparallax.com#example-max-transition)
171
+
The maxTransition setting controls the extent of the parallax animation. By default, it translates from 0% to 100% of the user's viewport. You can adjust this to any percentage.
134
172
135
-
### customContainer - *String or Node*
136
-
By default, the parallax calculation is done with the body scroll percentage. In some cases, the images may be in a container that has its own scroll area, so to have an accurate calculation, the custom container should be set.
173
+
### src - *String* - Vanilla version only
174
+
This is the source of the image. It can be a local path or a URL.
137
175
138
-
### customWrapper - *String*
139
-
In some cases, you want to use your own wrapper instead of the one created by the plugin. If you specify your custom wrapper, the plugin will add the "simpleParallax" class along with an "overflow: hidden" style.
176
+
### customContainer - *String or Node* - Vanilla version only
177
+
Parallax calculations default to the body scroll percentage. However, images may be in a container with its own scroll area. For accurate calculations, set a custom container.
140
178
141
-
### maxTransition - *Number* - see [example](https://simpleparallax.com#example-max-transition)
142
-
The maxTransition setting should be used to stop the parallax animation after a given percentage. By default, it translates from 0% to 100% of the user viewport. You can change it here to any percentage you want.
179
+
### customWrapper - *String* - Vanilla version only
180
+
In some instances, you might want to use your own wrapper instead of the plugin's. Specifying a custom wrapper will add the simpleParallax class and an overflow: hidden style.
0 commit comments