better js ...

This commit is contained in:
botsi 2020-02-03 22:52:01 +01:00
parent 0913ad786a
commit 9ba9fc334a
3 changed files with 12 additions and 2 deletions

View file

@ -76,6 +76,10 @@ div.footer-copyright li.pull-right a {
color: #fff; color: #fff;
} }
.back-top--hidden {
visibility: hidden;
}
span.caret.caret_up { span.caret.caret_up {
transform: rotate(180deg); transform: rotate(180deg);
} }

View file

@ -38,7 +38,13 @@ var Cl = window.Cl || {};
bodyContainer = document.querySelector('body>div.container'), bodyContainer = document.querySelector('body>div.container'),
shBackTop = function() { shBackTop = function() {
if (backTop && bodyContainer) { if (backTop && bodyContainer) {
backTop.style.opacity = +(bodyContainer.offsetTop + bodyContainer.getBoundingClientRect().height > window.innerHeight); if (bodyContainer.offsetTop + bodyContainer.getBoundingClientRect().height > window.innerHeight) {
if (backTop.classList.contains('back-top--hidden')) {
backTop.classList.remove('back-top--hidden');
}
} else if (!backTop.classList.contains('back-top--hidden')) {
backTop.classList.add('back-top--hidden');
}
} }
}; };
$(window).resize(shBackTop); $(window).resize(shBackTop);

View file

@ -111,7 +111,7 @@
<p class="footer-logo">&nbsp;</p> <p class="footer-logo">&nbsp;</p>
{% render_model_block request.current_page "changelist" %} {% render_model_block request.current_page "changelist" %}
<ul class="list-inline"> <ul class="list-inline">
<li class="pull-right"><a href="#page-top" data-spy="scroll">{% trans "Back to top" %} <span class="caret caret_up"></span></a></li> <li class="pull-right back-top-hidden"><a href="#page-top" data-spy="scroll">{% trans "Back to top" %} <span class="caret caret_up"></span></a></li>
{% show_menu_below_id "footer" 0 0 100 100 "includes/menu/navigation.html" %} {% show_menu_below_id "footer" 0 0 100 100 "includes/menu/navigation.html" %}
</ul> </ul>
{% endrender_model_block %} {% endrender_model_block %}