forked from johnggli/linktree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a "fix" for Parallax Star BG on Ultrawide Screens
Added a "fix" for Parallax Stars on Ultrawide Displays based on the following johnggli#11. Thanks to Pkrakmo https://github.com/Pkrakmo
- Loading branch information
1 parent
34c2d93
commit 6c22607
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Fix for Parallax Stars on Ultrawide Displays from https://github.com/johnggli/linktree/pull/11 | ||
// Thanks to Pkrakmo https://github.com/Pkrakmo | ||
|
||
const stars1 = [] | ||
const stars2 = [] | ||
const stars3 = [] | ||
|
||
const numberOfStars1 = '2700' | ||
const numberOfStars2 = '1625' | ||
const numberOfStars3 = '275' | ||
|
||
|
||
for (let i = 0; i < numberOfStars1; i++) { | ||
const pos1 = (Math.floor(Math.random() * 5200)) | ||
const pos2 = (Math.floor(Math.random() * 5200)) | ||
stars1.push(`${pos1}px ${pos2}px #fff`) | ||
} | ||
|
||
for (let i = 0; i < numberOfStars2; i++) { | ||
const pos1 = (Math.floor(Math.random() * 5200)) | ||
const pos2 = (Math.floor(Math.random() * 5200)) | ||
stars2.push(`${pos1}px ${pos2}px #fff`) | ||
} | ||
|
||
for (let i = 0; i < numberOfStars3; i++) { | ||
const pos1 = (Math.floor(Math.random() * 5200)) | ||
const pos2 = (Math.floor(Math.random() * 5200)) | ||
stars3.push(`${pos1}px ${pos2}px #fff`) | ||
} | ||
|
||
const addCSS = css => document.head.appendChild(document.createElement("style")).innerHTML = css; | ||
|
||
addCSS(`#stars1{ box-shadow:${stars1}}`) | ||
addCSS(`#stars1:after{ box-shadow:${stars1}}`) | ||
|
||
addCSS(`#stars2{ box-shadow:${stars2}}`) | ||
addCSS(`#stars2:after{ box-shadow:${stars2}}`) | ||
|
||
addCSS(`#stars3{ box-shadow:${stars3}}`) | ||
addCSS(`#stars3:after{ box-shadow:${stars3}}`) |
6c22607
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into index.html to avoid a separate call for the .js.
753b580