mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-21 05:29:31 -07:00
finish the basic scroll logic
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
import { imagesDivNodes as images } from './elemGen'
|
||||||
|
import { imagesArrayLen } from './dataFetch'
|
||||||
|
|
||||||
|
export const renderImages = (): void => {
|
||||||
|
images.forEach((img: HTMLImageElement, idx: number): void => {
|
||||||
|
const randomX: number = Math.floor(Math.random() * 35) + 2
|
||||||
|
let randomY: number
|
||||||
|
|
||||||
|
// random Y calculation
|
||||||
|
if (idx === 0) {
|
||||||
|
randomY = 68
|
||||||
|
} else if (idx === 1) {
|
||||||
|
randomY = 44
|
||||||
|
} else if (idx === imagesArrayLen - 1) {
|
||||||
|
randomY = 100
|
||||||
|
} else {
|
||||||
|
randomY = Math.floor(Math.random() * 51) + 2
|
||||||
|
}
|
||||||
|
|
||||||
|
img.style.transform = `translate(${randomX}vw, -${randomY}%)`
|
||||||
|
img.style.marginTop = `${idx === 1 ? 70 : 0}vh`
|
||||||
|
img.style.visibility = 'visible'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user