Fix console getting spammed with errors

Page actually jumps down once you exit image view
This commit is contained in:
Michał 2023-03-27 07:15:18 +00:00
parent 3331edf24d
commit 95a116ef50
3 changed files with 41 additions and 35 deletions

View file

@ -88,16 +88,19 @@ window.onload = function () {
// Info button
let infoButton = document.querySelector('.info-button');
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
infoButton.classList.remove('show');
} else {
infoButton.classList.add('show');
}
infoButton.onclick = function () {
popUpShow('OnlyLegs on Flask',
'Using <a href="https://phosphoricons.com/">Phosphoricons</a> and <a href="https://www.gent.media/manrope">Manrope</a> <br>' +
'Made by Fluffy and others with ❤️ <br>' +
'<a href="https://github.com/Fluffy-Bean/onlylegs">V23.03.26</a>');
if (infoButton) {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
infoButton.classList.remove('show');
} else {
infoButton.classList.add('show');
}
infoButton.onclick = function () {
popUpShow('OnlyLegs on Flask',
'Using <a href="https://phosphoricons.com/">Phosphoricons</a> and <a href="https://www.gent.media/manrope">Manrope</a> <br>' +
'Made by Fluffy and others with ❤️ <br>' +
'<a href="https://github.com/Fluffy-Bean/onlylegs">V23.03.26</a>');
}
}
};
window.onscroll = function () {
@ -113,10 +116,13 @@ window.onscroll = function () {
// Info button
let infoButton = document.querySelector('.info-button');
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
infoButton.classList.remove('show');
} else {
infoButton.classList.add('show');
if (infoButton) {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
infoButton.classList.remove('show');
} else {
infoButton.classList.add('show');
}
}
};
window.onresize = function () {

View file

@ -4,7 +4,7 @@
<meta property="og:image" content="{{ url_for('api.file', file_name=image.file_name) }}"/>
<meta name="theme-color" content="#{{ image.image_colours.0.0 }}{{ image.image_colours.0.1 }}{{ image.image_colours.0.2 }}"/>
<script>
<script type="text/javascript">
function imageFullscreenOff() {
document.querySelector("html").style.overflow = "auto";
let fullscreen = document.querySelector('.image-fullscreen')
@ -281,7 +281,7 @@
{% endblock %}
{% block script %}
<script>
<script type="text/javascript">
let infoTab = document.querySelectorAll('.info-tab');
for (let i = 0; i < infoTab.length; i++) {
infoTab[i].querySelector('.info-header').addEventListener('click', function() {

View file

@ -1,24 +1,5 @@
{% extends 'layout.html' %}
{% block nav_home %}selected{% endblock %}
{% block head %}
<script>
if (document.referrer.includes('image')) {
try {
let referrerId = document.referrer.split('/').pop();
let imgOffset = document.getElementById('image-' + referrerId).offsetTop;
let imgHeight = document.getElementById('image-' + referrerId).offsetHeight;
let windowHeight = window.innerHeight;
document.querySelector('html').style.scrollBehavior = 'auto';
window.scrollTo(0, imgOffset + (imgHeight / 2) - (windowHeight / 2));
document.querySelector('html').style.scrollBehavior = 'smooth';
} catch (e) {
console.log(e);
}
}
</script>
{% endblock %}
{% block content %}
<div class="banner small">
<div class="banner-content">
@ -52,3 +33,22 @@
</div>
{% endif %}
{% endblock %}
{% block script %}
<script>
if (document.referrer.includes('image')) {
try {
let referrerId = document.referrer.split('/').pop();
let imgOffset = document.getElementById('image-' + referrerId).offsetTop;
let imgHeight = document.getElementById('image-' + referrerId).offsetHeight;
let windowHeight = window.innerHeight;
document.querySelector('html').style.scrollBehavior = 'auto';
window.scrollTo(0, imgOffset + (imgHeight / 2) - (windowHeight / 2));
document.querySelector('html').style.scrollBehavior = 'smooth';
} catch (e) {
console.log(e);
}
}
</script>
{% endblock %}