Skip to content

Commit 2cdb1fc

Browse files
committed
✨ add a isInit class
1 parent 7cc7564 commit 2cdb1fc

File tree

7 files changed

+1221
-507
lines changed

7 files changed

+1221
-507
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v11.5.0
1+
lts/erbium

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Simply copy/paste the below snippet just before your closing `</body>` tag:
2424
or use the below CDN link provided by [jsDelivr.com](https://www.jsdelivr.com/package/npm/simple-parallax-js):
2525

2626
```html
27-
<script src="https://cdn.jsdelivr.net/npm/simple-parallax-js@5.5.1/dist/simpleParallax.min.js"></script>
27+
<script src="https://cdn.jsdelivr.net/npm/simple-parallax-js@5.6.1/dist/simpleParallax.min.js"></script>
2828
```
2929

3030
### Via [npm/yarn](https://www.npmjs.com/package/simple-parallax-js)
@@ -75,6 +75,8 @@ const images = document.querySelectorAll('img');
7575
new simpleParallax(images);
7676
```
7777

78+
Once simpleparallax has been correctly initialized, it adds the ```simple-parallax-initialized``` class on the container.
79+
7880
simpleParallax now works with video:
7981

8082
```html

dist/simpleParallax.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* simpleParallax - simpleParallax is a simple JavaScript library that gives your website parallax animations on any images or videos,
3-
* @date: 26-07-2020 15:48:32,
4-
* @version: 5.5.1,
3+
* @date: 26-07-2020 15:56:23,
4+
* @version: 5.6.1,
55
* @link: https://simpleparallax.com/
66
*/
77
(function webpackUniversalModuleDefinition(root, factory) {
@@ -311,8 +311,14 @@ var parallax_ParallaxInstance = /*#__PURE__*/function () {
311311
// apply a timeout to avoid buggy effect
312312
setTimeout(function () {
313313
// apply the transition style on the image
314-
_this2.setTransitionCSS();
314+
_this2.setTransitionCSS(); //add isInit class
315+
316+
317+
_this2.elementContainer.classList.add('simple-parallax-initialized');
315318
}, 10);
319+
} else {
320+
//add isInit class
321+
this.elementContainer.classList.add('simple-parallax-initialized');
316322
} // for some reason, <picture> are init an infinite time on windows OS
317323

318324

dist/simpleParallax.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1188 additions & 488 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-parallax-js",
3-
"version": "5.5.1",
3+
"version": "5.6.1",
44
"description": "simpleParallax is a simple JavaScript library that gives your website parallax animations on any images or videos",
55
"homepage": "https://simpleparallax.com/",
66
"main": "./dist/simpleParallax.min.js",
@@ -51,22 +51,22 @@
5151
"webpack-dev-server": "^3.11.0"
5252
},
5353
"devDependencies": {
54-
"@babel/core": "^7.10.2",
55-
"@babel/preset-env": "^7.10.2",
54+
"@babel/core": "^7.10.3",
55+
"@babel/preset-env": "^7.10.3",
5656
"babel-loader": "^8.1.0",
57-
"eslint": "^7.2.0",
58-
"eslint-config-airbnb-base": "^14.1.0",
57+
"eslint": "^7.3.0",
58+
"eslint-config-airbnb-base": "^14.2.0",
5959
"eslint-config-prettier": "^6.11.0",
60-
"eslint-plugin-import": "^2.20.2",
60+
"eslint-plugin-import": "^2.21.2",
6161
"eslint-plugin-node": "^11.1.0",
62-
"eslint-plugin-prettier": "^3.1.3",
62+
"eslint-plugin-prettier": "^3.1.4",
6363
"husky": "^4.2.5",
6464
"jest": "^26.0.1",
65-
"lint-staged": "^10.2.9",
66-
"moment": "^2.26.0",
65+
"lint-staged": "^10.2.11",
66+
"moment": "^2.27.0",
6767
"prettier": "^2.0.5",
68-
"terser-webpack-plugin": "^3.0.3",
68+
"terser-webpack-plugin": "^3.0.6",
6969
"uglifyjs-webpack-plugin": "^2.2.0",
70-
"webpack-cli": "^3.3.11"
70+
"webpack-cli": "^3.3.12"
7171
}
7272
}

src/instances/parallax.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ class ParallaxInstance {
7272
setTimeout(() => {
7373
// apply the transition style on the image
7474
this.setTransitionCSS();
75+
76+
//add isInit class
77+
this.elementContainer.classList.add('simple-parallax-initialized');
7578
}, 10);
79+
} else {
80+
//add isInit class
81+
this.elementContainer.classList.add('simple-parallax-initialized');
7682
}
7783

7884
// for some reason, <picture> are init an infinite time on windows OS

0 commit comments

Comments
 (0)