1
0
mirror of https://github.com/Damillora/Yuika synced 2024-11-05 02:17:32 +00:00
Yuika/index.hbs

75 lines
2.1 KiB
Handlebars
Raw Normal View History

2019-11-08 20:59:26 +00:00
{{!< default}}
2019-11-09 06:03:26 +00:00
<div class="h-64 relative index-header">
2019-11-08 20:59:26 +00:00
{{> header-background background=@site.cover_image}} {{!--Special header-image.hbs partial to generate the background image--}}
<div class="h-full opacity-50 bg-black">
</div>
</div>
2019-11-09 06:03:26 +00:00
<div class="w-full flex flex-row justify-begin items-center absolute top-0 index-navbar">
{{> "site-header"}}
2019-11-08 20:59:26 +00:00
</div>
</div>
2019-11-08 21:22:18 +00:00
<div class="container px-6 my-6 flex flex-wrap justify-between mx-auto post-feed">
2019-11-08 20:59:26 +00:00
{{#foreach posts}}
{{> "post-card"}}
{{/foreach}}
</div>
2019-11-09 06:03:26 +00:00
{{#contentFor "scripts"}}
<script>
$(document).ready(function () {
var nav = document.querySelector('.index-navbar');
var feed = document.querySelector('.post-feed');
var lastScrollY = window.scrollY;
var lastWindowHeight = window.innerHeight;
var lastDocumentHeight = $(document).height();
var ticking = false;
function onScroll() {
lastScrollY = window.scrollY;
requestTick();
}
function onResize() {
lastWindowHeight = window.innerHeight;
lastDocumentHeight = $(document).height();
requestTick();
}
function requestTick() {
if (!ticking) {
requestAnimationFrame(update);
}
ticking = true;
}
function update() {
var trigger = feed.getBoundingClientRect().top + window.scrollY;
var progressMax = lastDocumentHeight - lastWindowHeight;
// show/hide nav
if (lastScrollY >= trigger - 20) {
nav.classList.add('fixed');
nav.classList.add('nav-fixed');
nav.classList.remove('absolute');
} else {
nav.classList.remove('fixed');
nav.classList.remove('nav-fixed');
nav.classList.add('absolute');
}
ticking = false;
}
window.addEventListener('scroll', onScroll, { passive: true });
window.addEventListener('resize', onResize, false);
update();
});
</script>
{{/contentFor}}