Skip to content

Commit 8879c96

Browse files
authored
[bug] fix header shade when using reverse layout order
1 parent edd91ee commit 8879c96

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

‎src/css/header.css‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@
3838
.header-shade{
3939
background-color: transparent;
4040
content:"";
41-
display: block;
42-
position: absolute;
4341
width:100%;
4442
height:100%;
43+
display: block;
44+
position: absolute;
4545
top:0;
4646
left:0;
47-
opacity:0;
4847
pointer-events: none;
4948
transition: background-color var(--layout-transition-speed-slow) ease-in-out, opacity var(--layout-transition-speed-slow) ease-in-out, border-radius var(--layout-transition-speed-fast) ease-in-out;
5049
}
@@ -55,16 +54,7 @@
5554

5655
.is-header-shade-style-always .header-shade,
5756
.is-header-shade-style-scroll .header-shade{
58-
background-color:rgba(var(--header-shade-color));
59-
opacity:var(--header-shade-opacity);
60-
}
61-
62-
.is-header-border-top .header-shade{
63-
border-top:calc(var(--layout-line-width) *var(--header-border-top)) solid rgb(var(--theme-accent));
64-
}
65-
66-
.is-header-border-bottom .header-shade{
67-
border-bottom:calc(var(--layout-line-width) *var(--header-border-bottom)) solid rgb(var(--theme-accent));
57+
background-color:rgba(var(--header-shade-color),var(--header-shade-opacity));
6858
}
6959

7060
.header-area{
@@ -82,6 +72,24 @@
8272
border-bottom:calc(var(--layout-line-width) *var(--header-border-bottom)) solid transparent;
8373
}
8474

75+
.header-border{
76+
width:100%;
77+
height:100%;
78+
display: block;
79+
position: absolute;
80+
top:0;
81+
left:0;
82+
pointer-events: none;
83+
}
84+
85+
.is-header-border-top .header-border{
86+
border-top:calc(var(--layout-line-width) *var(--header-border-top)) solid rgb(var(--theme-accent));
87+
}
88+
89+
.is-header-border-bottom .header-border{
90+
border-bottom:calc(var(--layout-line-width) *var(--header-border-bottom)) solid rgb(var(--theme-accent));
91+
}
92+
8593
.is-header-radius .header-shade{
8694
border-radius:calc(var(--theme-radius) *4);
8795
}

‎src/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
<headerclass="header">
4949
<divclass="header-shade"></div>
50+
<divclass="header-border"></div>
5051
<divclass="header-area">
5152
<divclass="header-item-grid">
5253
<divclass="header-item header-greeting">

‎src/js/header.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ var header = (function(){
7777

7878
var_renderShade=function(){
7979
varhtml=helper.e("html");
80+
varheaderRect=helper.e(".header").getBoundingClientRect();
81+
varlayoutRect=helper.e(".layout").getBoundingClientRect();
8082
varfontSize=parseInt(getComputedStyle(html).fontSize,10);
8183
varscrollTop=document.documentElement.scrollTop;
82-
varscrollHeight=document.documentElement.scrollHeight;
84+
// var scrollHeight = document.documentElement.scrollHeight;
8385
varinnerHeight=window.innerHeight;
8486
// if shade show
8587
if(state.get().header.shade.show){
@@ -91,16 +93,16 @@ var header = (function(){
9193
}elseif(state.get().header.shade.style=="scroll"){
9294
helper.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){
9799
helper.addClass(html,"is-header-shade-style-scroll");
98100
}else{
99101
helper.removeClass(html,"is-header-shade-style-scroll");
100102
};
101103
}elseif(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))){
104106
helper.addClass(html,"is-header-shade-style-scroll");
105107
}else{
106108
helper.removeClass(html,"is-header-shade-style-scroll");

‎src/js/version.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
varversion=(function(){
22

3-
varcurrent="3.29.0";
3+
varcurrent="3.29.1";
44

55
varcompare=function(a,b){
66
varpa=a.split(".");

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nightTab",
33
"short_name": "nightTab",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
5-
"version": "3.29.0",
5+
"version": "3.29.1",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)