diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 641fda7fb..7862b02e1 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -7069,6 +7069,19 @@ body *::-webkit-scrollbar { cursor: default !important; } +#pulltorefresh { + align-content: center; + justify-content: center; + position: absolute; + top: 12px; + width: 100%; + display: flex; +} + +#pulltorefresh > img { + height: 50px; +} + body > .container { --safe-area-inset-left: env(safe-area-inset-left); --safe-area-inset-right: env(safe-area-inset-right); diff --git a/files/assets/js/pwa_pulltorefresh.js b/files/assets/js/pwa_pulltorefresh.js new file mode 100644 index 000000000..5dac57e5a --- /dev/null +++ b/files/assets/js/pwa_pulltorefresh.js @@ -0,0 +1,19 @@ +const standalone = navigator.standalone || window.matchMedia("(display-mode: standalone)").matches; +if (standalone) { + const img = document.getElementById("pulltorefresh-img"); + const defaultImg = "/e/marseythinkorino.webp"; + const thresholdImg = "/e/marseythumbsup.webp"; + const threshold = -100; + + window.addEventListener("touchend", () => { + if (window.scrollY < threshold) { + window.location.reload(); + } + }); + + window.addEventListener("scroll", () => { + img.setAttribute("src", window.scrollY < threshold ? thresholdImg : defaultImg); + }); +} else { + document.getElementById("pulltorefresh").remove(); +} diff --git a/files/templates/default.html b/files/templates/default.html index 79d7f8c5c..5693544c8 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -1,6 +1,11 @@ {%- extends 'root.html' -%} {% block body_attributes %}id="{% if request.path != '/comments' %}{% block pagetype %}frontpage{% endblock %}{% endif %}" class="has_header"{% endblock %} {% block body %} +{% block pulltorefresh %} +
+ +
+{% endblock %} {% block banner %} {% include "modals/expanded_image.html" %} {% if err or '@' not in request.path %} diff --git a/files/templates/root.html b/files/templates/root.html index acb4ea870..f5c28e0a0 100644 --- a/files/templates/root.html +++ b/files/templates/root.html @@ -43,5 +43,6 @@
{% endif %} +