|
|
|
@ -3,7 +3,12 @@ var customSearch; |
|
|
|
|
(function ($) { |
|
|
|
|
|
|
|
|
|
"use strict"; |
|
|
|
|
const scrollCorrection = 80; // (header height = 64px) + (gap = 16px)
|
|
|
|
|
var scrollCorrection = 80; // (header height = 64px) + (gap = 16px)
|
|
|
|
|
const $headerAnchor = $('.l_header', '.cover-wrapper'); |
|
|
|
|
if ($headerAnchor[0]) { |
|
|
|
|
scrollCorrection = $headerAnchor[0].clientHeight + 16; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function scrolltoElement(elem, correction) { |
|
|
|
|
correction = correction || scrollCorrection; |
|
|
|
|
const $elem = elem.href ? $(elem.getAttribute('href')) : $(elem); |
|
|
|
@ -15,7 +20,6 @@ var customSearch; |
|
|
|
|
const $postsBtn = $('.menu .active'); |
|
|
|
|
const $topBtn = $('.s-top'); |
|
|
|
|
// anchor
|
|
|
|
|
const $coverAnchor = $('.l_header', '.cover-wrapper'); |
|
|
|
|
const $bodyAnchor = $('.l_body'); |
|
|
|
|
// action
|
|
|
|
|
if ($postsBtn.length && $bodyAnchor) { |
|
|
|
@ -25,7 +29,12 @@ var customSearch; |
|
|
|
|
$topBtn.click(e => { e.preventDefault(); e.stopPropagation(); scrolltoElement($bodyAnchor); }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const showCoverPoint = document.body.clientHeight*0.6 - 100; |
|
|
|
|
const $coverAnchor = $('.cover-wrapper'); |
|
|
|
|
var showHeaderPoint = 0; |
|
|
|
|
if ($coverAnchor[0]) { |
|
|
|
|
showHeaderPoint = $coverAnchor[0].clientHeight - 64; |
|
|
|
|
} |
|
|
|
|
console.log(showHeaderPoint); |
|
|
|
|
var pos = document.body.scrollTop; |
|
|
|
|
$(document, window).scroll(() => { |
|
|
|
|
const scrollTop = $(window).scrollTop(); |
|
|
|
@ -41,10 +50,10 @@ var customSearch; |
|
|
|
|
} else { |
|
|
|
|
$topBtn.removeClass('show').removeClass('hl'); |
|
|
|
|
} |
|
|
|
|
if (scrollTop > document.body.clientHeight*0.6 - 100) { |
|
|
|
|
$coverAnchor.addClass('show'); |
|
|
|
|
if (scrollTop > showHeaderPoint) { |
|
|
|
|
$headerAnchor.addClass('show'); |
|
|
|
|
} else { |
|
|
|
|
$coverAnchor.removeClass('show'); |
|
|
|
|
$headerAnchor.removeClass('show'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|