Skip to content

Commit

Permalink
Added a "fix" for Parallax Star BG on Ultrawide Screens
Browse files Browse the repository at this point in the history
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
paramedicspecialist authored Sep 16, 2023
1 parent 34c2d93 commit 6c22607
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions mods/ultrawide-parallax-stars-patch.js
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}}`)

1 comment on commit 6c22607

@paramedicspecialist
Copy link
Owner Author

@paramedicspecialist paramedicspecialist commented on 6c22607 Sep 16, 2023

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

Please sign in to comment.