A recreation of the interactive image gallery effect from: https://bridget.pictures.
A Pen by Hyperplexed on CodePen.
<img class="image" data-index="0" data-status="inactive" src="https://media.discordapp.net/attachments/1064223668516958248/1064224255404953610/gen2_announcement.png?width=1000&height=1000" /> | |
<img class="image" data-index="1" data-status="inactive" src="https://media.discordapp.net/attachments/1064223668516958248/1064224474167259238/METAME_HQ_banner_twitter.png" /> | |
<img class="image" data-index="2" data-status="inactive" src="https://media.discordapp.net/attachments/1064223668516958248/1064225452631265350/unknown.png" /> | |
<img class="image" data-index="3" data-status="inactive" src="https://media.discordapp.net/attachments/1064223668516958248/1064228161971290122/unknown.png" /> | |
<img class="image" data-index="4" data-status="inactive" src="https://media.discordapp.net/attachments/1064223668516958248/1064228290451230830/image0.png?width=976&height=579" /> | |
<img class="image" data-index="5" data-status="inactive" src="https://media.discordapp.net/attachments/1064223668516958248/1074827011136159844/image.png?width=581&height=579" /> | |
<img class="image" data-index="6" data-status="inactive" src="https://shdw-drive.genesysgo.net/HfbS7SkXU3FurmPE5uGJucNiWuJYvbxQXCXJKHLd1oNG/2.png" /> | |
<img class="image" data-index="7" data-status="inactive" src="https://shdw-drive.genesysgo.net/HfbS7SkXU3FurmPE5uGJucNiWuJYvbxQXCXJKHLd1oNG/239.png" /> | |
<img class="image" data-index="8" data-status="inactive" src="https://shdw-drive.genesysgo.net/HfbS7SkXU3FurmPE5uGJucNiWuJYvbxQXCXJKHLd1oNG/54.png" /> | |
<img class="image" data-index="9" data-status="inactive" src="https://shdw-drive.genesysgo.net/HfbS7SkXU3FurmPE5uGJucNiWuJYvbxQXCXJKHLd1oNG/203.png" /> | |
<a id="source-link" class="meta-link" href="https://bridget.pictures" target="_blank"> | |
<i class="fa-solid fa-link"></i> | |
<span>Source</span> | |
</a> | |
<a id="yt-link" class="meta-link" href="https://youtu.be/Jt3A2lNN2aE" target="_blank"> | |
<i class="fa-brands fa-youtube"></i> | |
<span>3 min tutorial</span> | |
</a> |
A recreation of the interactive image gallery effect from: https://bridget.pictures.
A Pen by Hyperplexed on CodePen.
const images = document.getElementsByClassName("image"); | |
let globalIndex = 0, | |
last = { x: 0, y: 0 }; | |
const activate = (image, x, y) => { | |
image.style.left = `${x}px`; | |
image.style.top = `${y}px`; | |
image.style.zIndex = globalIndex; | |
image.dataset.status = "active"; | |
last = { x, y }; | |
} | |
const distanceFromLast = (x, y) => { | |
return Math.hypot(x - last.x, y - last.y); | |
} | |
const handleOnMove = e => { | |
if(distanceFromLast(e.clientX, e.clientY) > (window.innerWidth / 20)) { | |
const lead = images[globalIndex % images.length], | |
tail = images[(globalIndex - 5) % images.length]; | |
activate(lead, e.clientX, e.clientY); | |
if(tail) tail.dataset.status = "inactive"; | |
globalIndex++; | |
} | |
} | |
window.onmousemove = e => handleOnMove(e); | |
window.ontouchmove = e => handleOnMove(e.touches[0]); |
<script src="https://kit.fontawesome.com/944eb371a4.js"></script> |
body { | |
background-color: black; | |
height: 100vh; | |
margin: 0px; | |
overflow: hidden; | |
} | |
.image { | |
width: 40vmin; | |
position: absolute; | |
transform: translate(-50%, -50%); | |
} | |
.image[data-status="inactive"] { | |
display: none; | |
} | |
.image[data-status="active"] { | |
display: block; | |
}} | |
/* -- YouTube Link Styles -- */ | |
body.menu-toggled > .meta-link > span { | |
color: rgb(30, 30, 30); | |
} | |
#source-link { | |
bottom: 60px; | |
} | |
#source-link > i { | |
color: rgb(94, 106, 210); | |
} | |
#yt-link > i { | |
color: rgb(239, 83, 80); | |
} | |
.meta-link { | |
align-items: center; | |
backdrop-filter: blur(3px); | |
background-color: rgba(255, 255, 255, 0.05); | |
border: 1px solid rgba(255, 255, 255, 0.1); | |
border-radius: 6px; | |
bottom: 10px; | |
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1); | |
cursor: pointer; | |
display: inline-flex; | |
gap: 5px; | |
left: 10px; | |
padding: 10px 20px; | |
position: fixed; | |
text-decoration: none; | |
transition: background-color 400ms, border-color 400ms; | |
z-index: 10000; | |
} | |
.meta-link:hover { | |
background-color: rgba(255, 255, 255, 0.1); | |
border: 1px solid rgba(255, 255, 255, 0.2); | |
} | |
.meta-link > i, .meta-link > span { | |
height: 20px; | |
line-height: 20px; | |
} | |
.meta-link > span { | |
color: white; | |
font-family: "Rubik", sans-serif; | |
font-weight: 500; | |
} |