Fix jumpUp button

Switch to reffere instead of src url
Once again, I am changing animations
This commit is contained in:
Michał Gdula 2023-02-01 00:57:36 +00:00
parent f845f614df
commit a9b13f1e39
7 changed files with 38 additions and 22 deletions

View file

@ -6,7 +6,6 @@
<span></span>
</div>
{% endblock %}
{% block scrollPosition %}?src={{ image['id'] }}{% endblock %}
{% block wrapper_class %}image-wrapper{% endblock %}
{% block content %}
@ -209,10 +208,15 @@
{% block script %}
<script>
var collapseButton = document.querySelectorAll('#collapse-info');
for (var i = 0; i < collapseButton.length; i++) {
collapseButton[i].addEventListener('click', function() {
var infoCollapse = document.querySelectorAll('#collapse-info');
for (var i = 0; i < infoCollapse.length; i++) {
infoCollapse[i].addEventListener('click', function() {
this.parentNode.classList.toggle('image-info__collapsed');
});
}
var infoHeader = document.querySelectorAll('.image-info__header');
for (var i = 0; i < infoHeader.length; i++) {
infoHeader[i].addEventListener('click', function() {
this.parentNode.classList.toggle('image-info__collapsed');
});
}

View file

@ -45,13 +45,13 @@
loadOnView();
};
const urlParams = new URLSearchParams(window.location.search);
const src = urlParams.get('src');
if (src) {
var imgOffset = document.getElementById('image-' + src).offsetTop;
var imgHeight = document.getElementById('image-' + src).offsetHeight;
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;
var windowHeight = window.innerHeight;
document.querySelector('html').style.scrollBehavior = 'auto';
window.scrollTo(0, imgOffset + (imgHeight / 2) - (windowHeight / 2));
document.querySelector('html').style.scrollBehavior = 'smooth';

View file

@ -18,7 +18,7 @@
{% block header %}{% endblock %}
<div class="navigation">
<a href="{{url_for('gallery.index')}}{% block scrollPosition %}{% endblock %}" class="navigation-item {% block nav_home %}{% endblock %}">
<a href="{{url_for('gallery.index')}}" class="navigation-item {% block nav_home %}{% endblock %}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24" width="24" fill="currentColor">
<path d="M2 8v10h12V8H2zm2-2V2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2v4a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2zm2 0h8a2 2 0 0 1 2 2v4h2V2H6v4zm0 9a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"></path><path d="M7 6a3 3 0 1 1 6 0h-2a1 1 0 0 0-2 0H7zm1.864 13.518l2.725-4.672a1 1 0 0 1 1.6-.174l1.087 1.184 1.473-1.354-1.088-1.183a3 3 0 0 0-4.8.52L7.136 18.51l1.728 1.007zm6.512-12.969a2.994 2.994 0 0 1 3.285.77l1.088 1.183-1.473 1.354-1.087-1.184A1 1 0 0 0 16 8.457V8c0-.571-.24-1.087-.624-1.451z"></path>
</svg>