blob: 961242e1cbe2abecc44f5c57df73796b54d0111c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
let scrollPosition = 0;
function clickToView() {
if (scrollPosition === 0) {
scrollPosition = window.scrollY;
window.scrollTo(0, 0);
}
this.classList.toggle('clicked-image');
document.body.classList.toggle('body-on-clicked-image');
if (!this.classList.contains('clicked-image')) {
window.scrollTo(0, scrollPosition);
scrollPosition = 0;
}
}
const images = document.getElementsByTagName('img');
for (const image of images) {
if (image.alt !== '🔗' && image.id !== 'scrollBtn') {
image.onclick = clickToView;
}
}
|