できたよー^^
$(function(){
const $header = $('.l-header');
const header_height = $header.outerHeight();
const winHeight = $(window).height();
let prev_scroll = 0;
$(window).on('scroll', function () {
var scroll = $(this).scrollTop();
$header.text('scroll:'+scroll);
if (prev_scroll > scroll || scroll > winHeight && scroll < winHeight + 500) {
$header.css('top', '0px');
} else {
$header.css('top', '-' + header_height + 'px');
}
prev_scroll = scroll;
}).scroll();
});
Like!