Entry action buttons displayed on page end reached

This commit is contained in:
Simounet 2020-01-19 17:49:54 +01:00
parent cfd77d1c2a
commit dc23bf9f29
No known key found for this signature in database
GPG key ID: 77D3B7DC794EB770
5 changed files with 28 additions and 11 deletions

View file

@ -5,6 +5,7 @@
#article { #article {
font-size: 20px; font-size: 20px;
margin: 0 auto; margin: 0 auto;
padding-bottom: 80px;
max-width: 45em; max-width: 45em;
article { article {

View file

@ -24,6 +24,29 @@ const stickyNav = () => {
}); });
}; };
const articleScroll = () => {
const articleEl = $('#article');
if (articleEl.length > 0) {
$(window).scroll(() => {
const s = $(window).scrollTop();
const d = $(document).height();
const c = $(window).height();
const articleElBottom = articleEl.offset().top + articleEl.height();
const scrollPercent = (s / (d - c)) * 100;
$('.progress .determinate').css('width', `${scrollPercent}%`);
const fixedActionBtn = $('.js-fixed-action-btn');
const toggleScrollDataName = 'toggle-auto';
if ((s + c) > articleElBottom) {
fixedActionBtn.data(toggleScrollDataName, true);
fixedActionBtn.openFAB();
} else if (fixedActionBtn.data(toggleScrollDataName) === true) {
fixedActionBtn.data(toggleScrollDataName, false);
fixedActionBtn.closeFAB();
}
});
}
};
$(document).ready(() => { $(document).ready(() => {
// sideNav // sideNav
$('.button-collapse').sideNav(); $('.button-collapse').sideNav();
@ -44,6 +67,7 @@ $(document).ready(() => {
initExport(); initExport();
initRandom(); initRandom();
stickyNav(); stickyNav();
articleScroll();
const toggleNav = (toShow, toFocus) => { const toggleNav = (toShow, toFocus) => {
$('.nav-panel-actions').hide(100); $('.nav-panel-actions').hide(100);
@ -81,12 +105,4 @@ $(document).ready(() => {
$('.nav-panels').css('background', 'transparent'); $('.nav-panels').css('background', 'transparent');
return false; return false;
}); });
$(window).scroll(() => {
const s = $(window).scrollTop();
const d = $(document).height();
const c = $(window).height();
const scrollPercent = (s / (d - c)) * 100;
$('.progress .determinate').css('width', `${scrollPercent}%`);
});
}); });

View file

@ -280,7 +280,7 @@
{{ entry.content | raw }} {{ entry.content | raw }}
</article> </article>
<div class="fixed-action-btn horizontal click-to-toggle hide-on-large-only"> <div class="fixed-action-btn js-fixed-action-btn horizontal click-to-toggle hide-on-large-only">
<a class="btn-floating btn-large" data-toggle="actions"> <a class="btn-floating btn-large" data-toggle="actions">
<i class="material-icons">menu</i> <i class="material-icons">menu</i>
</a> </a>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long