@@ -77,9 +77,11 @@ var header = (function(){
7777
7878var _renderShade = function ( ) {
7979var html = helper . e ( "html" ) ;
80+ var headerRect = helper . e ( ".header" ) . getBoundingClientRect ( ) ;
81+ var layoutRect = helper . e ( ".layout" ) . getBoundingClientRect ( ) ;
8082var fontSize = parseInt ( getComputedStyle ( html ) . fontSize , 10 ) ;
8183var scrollTop = document . documentElement . scrollTop ;
82- var scrollHeight = document . documentElement . scrollHeight ;
84+ // var scrollHeight = document.documentElement.scrollHeight;
8385var innerHeight = window . innerHeight ;
8486// if shade show
8587if ( state . get ( ) . header . shade . show ) {
@@ -91,16 +93,16 @@ var header = (function(){
9193} else if ( state . get ( ) . header . shade . style == "scroll" ) {
9294helper . removeClass ( html , "is-header-shade-style-always" ) ;
9395// check header position
94- if ( state . get ( ) . layout . order == "headerLink " ) {
96+ if ( state . get ( ) . layout . order == "headerlink " ) {
9597// check scroll position
96- if ( scrollTop > fontSize * 2 ) {
98+ if ( scrollTop > fontSize * 2 && headerRect . top == 0 ) {
9799helper . addClass ( html , "is-header-shade-style-scroll" ) ;
98100} else {
99101helper . removeClass ( html , "is-header-shade-style-scroll" ) ;
100102} ;
101103} else if ( state . get ( ) . layout . order == "linkheader" ) {
102104// check scroll position
103- if ( scrollTop < ( scrollHeight - innerHeight ) - ( fontSize * 2 ) ) {
105+ if ( headerRect . bottom == innerHeight && ( scrollTop + innerHeight ) < ( ( scrollTop + layoutRect . bottom ) - ( fontSize * 2 ) ) ) {
104106helper . addClass ( html , "is-header-shade-style-scroll" ) ;
105107} else {
106108helper . removeClass ( html , "is-header-shade-style-scroll" ) ;
0 commit comments