Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxodin committed Oct 7, 2021
1 parent 94bb17a commit 3531446
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ https://raw.githack.com/u1ui/parallax-bg.el/main/tests/visible.html
Create a element "u1-parallax-bg". It will be the parallax background of the closest element with the class `u1-parallax-bg-stage` or the closest positioned element (offsetParent).

```js
import 'https://cdn.jsdelivr.net/gh/u1ui/parallax-bg.el@3.3.5/parallax-bg.min.js';
import 'https://cdn.jsdelivr.net/gh/u1ui/parallax-bg.el@3.3.6/parallax-bg.min.js';
```

```html
<link rel=stylesheet href="https://cdn.jsdelivr.net/gh/u1ui/parallax-bg.el@3.3.5/parallax-bg.min.css">
<link rel=stylesheet href="https://cdn.jsdelivr.net/gh/u1ui/parallax-bg.el@3.3.6/parallax-bg.min.css">

<div class=u1-parallax-bg-stage>

Expand Down
6 changes: 4 additions & 2 deletions parallax-bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const paraxBg = {

// cache dimensions. Is it worth it?
let pageY = pageYOffset;
let winHeight = document.documentElement.clientHeight; // was innerHeight // better this?: https://stackoverflow.com/questions/1248081/how-to-get-the-browser-viewport-dimensions
//let winHeight = document.documentElement.clientHeight; // was innerHeight // better this?: https://stackoverflow.com/questions/1248081/how-to-get-the-browser-viewport-dimensions
let winHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
let scrollHeight = document.documentElement.scrollHeight;

function addListeners(){
Expand All @@ -44,7 +45,8 @@ function addListeners(){

addEventListener('resize', ()=>{
pageY = pageYOffset;
winHeight = document.documentElement.clientHeight; // was innerHeight
//winHeight = document.documentElement.clientHeight; // was innerHeight
winHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
scrollHeight = document.documentElement.scrollHeight;
paraxBg.layout();
paraxBg.positionize();
Expand Down

0 comments on commit 3531446

Please sign in to comment.