blob: 1683107e08eab7fae8a2c72e880d3a5e274b932d (
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.className.length === 0) {
window.scrollTo(0, scrollPosition);
scrollPosition = 0;
}
}
const images = document.getElementsByTagName('img');
for (const image of images) {
if (image.alt !== '🔗') {
image.onclick = clickToView;
}
}
|