2022-12-01 18:48:31 +00:00
|
|
|
{% extends 'layout.html' %}
|
2023-01-10 12:39:29 +00:00
|
|
|
|
2023-01-25 15:13:56 +00:00
|
|
|
{% block nav_home %}navigation-item__selected{% endblock %}
|
|
|
|
{% block wrapper_class %}index-wrapper{% endblock %}
|
2023-01-10 12:39:29 +00:00
|
|
|
|
2022-12-01 18:48:31 +00:00
|
|
|
{% block content %}
|
2023-01-25 15:13:56 +00:00
|
|
|
<div class="gallery">
|
|
|
|
{% for image in images %}
|
2023-01-26 14:43:08 +00:00
|
|
|
<a id="image-{{ image['id'] }}" class="gallery__item" href="/image/{{ image['id'] }}">
|
|
|
|
<span class="gallery__item-info">
|
2023-01-25 15:13:56 +00:00
|
|
|
<p>{{ image['id'] }}</p>
|
2023-01-26 16:55:42 +00:00
|
|
|
<h2><span class="time">{{ image['created_at'] }}</span></h2>
|
2023-01-26 14:43:08 +00:00
|
|
|
</span>
|
2023-01-25 15:13:56 +00:00
|
|
|
<img
|
|
|
|
class="gallery__item-image"
|
2023-01-26 16:55:42 +00:00
|
|
|
data-src="{{ image['file_name'] }}"
|
2023-01-25 15:13:56 +00:00
|
|
|
onload="imgFade(this)"
|
|
|
|
style="opacity:0;"
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
{% endfor %}
|
2022-12-01 18:48:31 +00:00
|
|
|
</div>
|
2023-01-25 15:13:56 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block script %}
|
2022-12-01 18:48:31 +00:00
|
|
|
<script>
|
2023-01-31 17:32:22 +00:00
|
|
|
function loadOnView() {
|
|
|
|
var images = document.querySelectorAll('.gallery__item-image');
|
2023-01-26 16:55:42 +00:00
|
|
|
for (var i = 0; i < images.length; i++) {
|
|
|
|
var image = images[i];
|
|
|
|
if (image.getBoundingClientRect().top < window.innerHeight && image.getBoundingClientRect().bottom > 0) {
|
|
|
|
if (!image.src) {
|
|
|
|
image.src = `/api/uploads/${image.getAttribute('data-src')}/400`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-31 17:32:22 +00:00
|
|
|
}
|
|
|
|
window.onload = function() {
|
|
|
|
loadOnView();
|
2023-01-26 16:55:42 +00:00
|
|
|
};
|
|
|
|
window.onscroll = function() {
|
2023-01-31 17:32:22 +00:00
|
|
|
loadOnView();
|
|
|
|
};
|
|
|
|
window.onresize = function() {
|
|
|
|
loadOnView();
|
2023-01-26 16:55:42 +00:00
|
|
|
};
|
|
|
|
|
2023-02-01 00:57:36 +00:00
|
|
|
if (document.referrer.includes('image')) {
|
|
|
|
var referrerId = document.referrer.split('/').pop();
|
|
|
|
|
|
|
|
var imgOffset = document.getElementById('image-' + referrerId).offsetTop;
|
|
|
|
var imgHeight = document.getElementById('image-' + referrerId).offsetHeight;
|
2023-01-26 14:43:08 +00:00
|
|
|
var windowHeight = window.innerHeight;
|
2023-02-01 00:57:36 +00:00
|
|
|
|
2023-01-26 14:43:08 +00:00
|
|
|
document.querySelector('html').style.scrollBehavior = 'auto';
|
|
|
|
window.scrollTo(0, imgOffset + (imgHeight / 2) - (windowHeight / 2));
|
|
|
|
document.querySelector('html').style.scrollBehavior = 'smooth';
|
2022-12-14 19:55:40 +00:00
|
|
|
}
|
2022-12-01 18:48:31 +00:00
|
|
|
</script>
|
|
|
|
{% endblock %}
|