Skip to content

Commit

Permalink
Merge branch 'non3D' of https://github.com/bcc-code/bible-explorers i…
Browse files Browse the repository at this point in the history
…nto non3D
  • Loading branch information
cs1m0n committed Apr 11, 2024
2 parents 5c98689 + da2c973 commit 6176f4b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Experience/Extras/Congrats.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ export default class Congrats {
}
const centralRect = centralElement.getBoundingClientRect()

const marginWidth = window.innerWidth * 0.2 // 20% of viewport width
const marginHeight = window.innerHeight * 0.2 // 20% of viewport height

names.forEach((name) => {
let randomX, randomY, overlap

do {
overlap = false
randomX = Math.random() * (window.innerWidth - name.offsetWidth)
randomY = Math.random() * (window.innerHeight - name.offsetHeight)
// Adjust calculations to consider margins
randomX = marginWidth + Math.random() * (window.innerWidth - 2 * marginWidth - name.offsetWidth)
randomY = marginHeight + Math.random() * (window.innerHeight - 2 * marginHeight - name.offsetHeight)

// Check if the random position overlaps with the central element
overlap = randomX < centralRect.right && randomX + name.offsetWidth > centralRect.left && randomY < centralRect.bottom && randomY + name.offsetHeight > centralRect.top
} while (overlap)

Expand Down

0 comments on commit 6176f4b

Please sign in to comment.